Comment ArrayList contient méthode de travail?

J'ai un doute sur la façon ArrayList contient méthode fonctionne. Prenons un exemple:

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");

il retourne "pas contient'.

Un autre exemple:

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");

Il retourne contient. Alors, comment ne contient méthode fonctionne ?

Grâce

InformationsquelleAutor AlessioG | 2013-09-20