I want to speed up the my code. Quick status information:
There is more than one list (
String) like_list1,_list2,_list3.I try to find a word (
String) in these lists.If I find a word, I will use index of the word on the list.
Here is my code:
private static int foundIndex (String s)
{
if (_list1.contains(s)) {
return _list1.indexOf(s);
} else if (_list2.contains(s)) {
return _list2.indexOf(s);
} else if (_list3.contains(s)) {
return _list3.indexOf(s);
} else if (_list4.contains(s)) {
return _list4.indexOf(s);
}
...
...
...
...
} else if (_list100.contains(s)) {
return _list100.indexOf(s);
}
return -1;
}
How can I speed up the my code?
sto an index in aMap<String, Integer>._list1,_list2, ...,_list99, and_list100is really bad code.