Mutation trick

Report a typo

Enter the size of the HashSet for the case where both hashCode() and equals() are not overridden.

    Person james = new Person("James Gosling");
        
    Set<Person> set = new HashSet();
    set.add(james);
    set.add(new Person("James Gosling"));

    System.out.println(set.size());
Enter a number
___

Create a free account to access the full topic