Unique pairs in HashMap

Report a typo

Implement the Person class to have a HashMap filled with unique pairs where the key is of Person type.

Sample Input 1:

James Gosling
James Gosling

Sample Output 1:

1
Write a program in Java 17
import java.util.Scanner;
import java.util.*;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Map<Person, Integer> map = new HashMap();
map.put(new Person(scanner.nextLine()), 1995);
map.put(new Person(scanner.nextLine()), 1995);

System.out.println(/* Print the map size here */);
}
}

class Person {
}
___

Create a free account to access the full topic