fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static class Employee{
  11. String name;
  12. int salary;
  13.  
  14. Employee(name,salary){
  15. this.name=name;
  16. this.salary=salary;
  17. }
  18. }
  19. public static class EmpComparator extends Comparator<Employee>{
  20. public int compare(Employee o1,Employee o2){
  21. if(o1.name==o2.name){
  22. if(o1.salary>o2.salary)
  23. return 1;
  24. else
  25. return 0;
  26. }
  27. else if(o1.name>o2.name)
  28. return 1;
  29. else
  30. return 0;
  31. }
  32. }
  33. public static void main (String[] args) throws java.lang.Exception
  34. {
  35. Scanner sc= new Scanner(System.in);
  36. int t= sc.nextInt();
  37. while(t-->0){
  38. Set<Employee> hash= new HashSet<Employee>();
  39. int x=sc.nextInt();
  40. while(x-->0){
  41. String z=sc.next();
  42. int b=sc.nextInt();
  43. hash.add(new Employee(z,b));
  44. }
  45. Collections.sort(hash,new EmpComparator());
  46. Iterator it= hash.iterator();
  47. while(it.hashNext()){
  48. Employee e=it.next();
  49. System.out.print(e.name+" "+e.salary);
  50. }
  51. System.out.println();
  52. }
  53. }
  54. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
2
xbnnskd 100 geek 50
2
shyam 50 ram 50
compilation info
Main.java:14: error: <identifier> expected
		Employee(name,salary){
		             ^
Main.java:14: error: <identifier> expected
		Employee(name,salary){
		                    ^
2 errors
stdout
Standard output is empty