The Sample Code which needs a solution?
public class TestJJava {
public static void main(String[] args) {
// TODO Auto-generated method stub
You are not comparing the full String
in the list but rather a substring of one of strings in the list.
You will have to loop through the list and check with each String
individually.
String temp = abc.substring(0,3);
boolean flag = true;
for(String value: lstValues.subList(0, 3))
if(value.contains(temp)) // or if(value.indexOf(temp) != -1)
{
System.out.println("**** Match Found ****");
flag = false;
break;
}
if(flag)
System.out.println("**** No Match Found ****");