Question: import java.util. * ; public class Test { public static void main ( String [ ] args ) { Set set = new HashSet (

import java.util.*; public class Test {
public static void main(String[] args){ Set set = new HashSet(); set.add(new A());
set.add(new A());
set.add(new A()); set.add(new A()); System.out.println(set);
}}
class A { int r =1;
public String toString(){ return r +"";
}
public boolean equals(Object o){ return this.r ==((A)o).r;
}
public int hashCode(){ return r;
}}
a.[1]
b.[1,1]
c.[1,1,1]
d.[1,1,1,1]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!