dimanche 1 mars 2015

wrapper class and normal string declaration gives same output?

I tried below given examples



String s=new String("cat");
String s1=new String("cat");
System.out.println(s==s1);
System.out.println(s.equals(s1));


this gives me output false and true.



String s="cat";
String s1="cat";
System.out.println(s==s1);
System.out.println(s.equals(s1));


in this case the output of both is true may i know the difference between both i heard both wrapper class and normal string declaration gives same output


Aucun commentaire:

Enregistrer un commentaire