Simple Question:Output of below Java program
- by Abhishek Jain
public class abc1 {
private String s;
public abc1(String s){this.s=s;}
public static void main(String args[])
{
HashSet<Object> hs=new HashSet<Object>();
abc1 a1= new abc1("abc");
abc1 a2= new abc1("abc");
String s1= new String("abc");
String s2= new String("abc");
hs.add(a1);
hs.add(a2);
hs.add(s1);
hs.add(s2);
System.out.println(hs.size());
}
}
Why above program output is 3?