I have a list here:
List<QueryStrings> queryStrings
and QueryStrings is just a simple class
public class QueryStrings {
    private Integer id;
    private String rel;
    private String impl;
}
I need to put the List into a HashMap where the id will be the key, I am doing it like this right now, looping the List one item at a time:
HashMap<Integer, QueryStrings> queryMap = new HashMap<>();
for (QueryStrings element : queryStrings) {
    Integer thisId = Integer.parseInt(element.getId());
    queryMap.put(thisId, element);
}
Is there a better way to this? I do not want to loop each items, is that possible?
Edit:
Sorry I should not parse the integer, so the code should look like:
HashMap<Integer, QueryStrings> queryMap = new HashMap<>();
for (QueryStrings element : queryStrings) {
    queryMap.put(element.getId(), element);
}
 
    