fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7.  
  8.  
  9. class MyBasicOperations {
  10.  
  11. public static void main(String a[]){
  12. HashMap<Person, String> hm = new HashMap<Person, String>();
  13. //add key-value pair to TreeMap
  14. Person key1= new Person();
  15. Person key2= new Person();
  16. Person key3= new Person();
  17. hm.put(key1, "FIRST INSERTED");
  18. hm.put(key2, "SECOND INSERTED");
  19. hm.put(key3,"THIRD INSERTED");
  20. System.out.println("Size of the TreeMap: "+hm.size());
  21. //System.out.println(hm);
  22. //getting value for the given key from TreeMap
  23. //System.out.println("Value of second: "+hm.get());
  24. System.out.println("Is TreeMap empty? "+hm.isEmpty());
  25. hm.remove(key1);
  26. // System.out.println(hm);
  27. System.out.println("Size of the TreeMap: "+hm.size());
  28. }
  29. }
  30. class Person{
  31. int a;
  32. Person(int a){
  33. this.a=a;
  34. }
  35. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:14: error: constructor Person in class Person cannot be applied to given types;
        Person key1= new Person();
                     ^
  required: int
  found: no arguments
  reason: actual and formal argument lists differ in length
Main.java:15: error: constructor Person in class Person cannot be applied to given types;
        Person key2= new Person();
                     ^
  required: int
  found: no arguments
  reason: actual and formal argument lists differ in length
Main.java:16: error: constructor Person in class Person cannot be applied to given types;
        Person key3= new Person();
                     ^
  required: int
  found: no arguments
  reason: actual and formal argument lists differ in length
3 errors
stdout
Standard output is empty