ham ham - 1 year ago 97
Java Question

what is the most efficient way to sweep a list

i have a large list of tuples

List<Tuple2<String,String> list;

what is the most efficient way to sweep it to search an element to retreive it or modify it??

for eg:

String elementToSearch="l";
Tuple2<String,String> result=(l,mm)

i tried that using the loop "for", it worked, but because it s a large list, i am not sure if it is the best way to do it.

Answer Source

You probably need a Map...

Map<String, String> myMap = new HashMap<>();

myMap.put("a", "bb");

String result = myMap.get("a");
//result will be "bb"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download