'Better way to search a list of objects in java

I have an object for servers with hostname and some sort of other fields. I'm searching my Database and get a List<Server>. So now I have another list of orders, which have besides some other fields a field for hostname.

At the moment I'm either iterating through list 1, get the hostname and then iterate trough list 2 and try to find the equal hostname, or I'm not making a list of servers but a HashMap<Hostname, Server> and look with contains if there is my hostname.

I want to know if there is a more elegant way to do this?



Solution 1:[1]

To answer the question: when a map of objects with a key is the best way, then that ist all I need to know.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Daniel Becker