Simple Question:Output of below Java program

Posted by Abhishek Jain on Stack Overflow See other posts from Stack Overflow or by Abhishek Jain
Published on 2010-04-28T17:07:32Z Indexed on 2010/04/28 17:13 UTC
Read the original article Hit count: 213

Filed under:
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?

© Stack Overflow or respective owner

Related posts about java