HashSet element mutations

Report a typo

What is the size of the HashSet if hashCode() and equals() are not overridden?

    Person james = new Person("James Gosling");

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

    james.setName("J. Gosling");
    set.add(new Person("J. Gosling"));

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

Create a free account to access the full topic