I've a doubt about how ArrayList contains method works. Let's take an example:
List<String> lstStr = new ArrayList<String>();
String tempStr1 = new String("1");
String tempStr2 = new String("1");
lstStr.add(tempStr1);
if (lst.contains(tempStr2))
System.out.println("contains");
else
System.out.println("not contains");
it returns 'not contains'.
Another example:
List<LinkProfileGeo> lst = new ArrayList<LinkProfileGeo>();
LinkProfileGeo temp1 = new LinkProfileGeo();
temp1.setGeoCode("1");
LinkProfileGeo temp2 = new LinkProfileGeo();
temp2.setGeoCode("1");
lst.add(temp1);
if (lst.contains(temp2))
System.out.println("contains");
else
System.out.println("not contains");
It returns contains. So how does contains method works ?
Thanks