fork download
  1. class typcasting
  2. {
  3. public static void main(String args[])
  4. {
  5. overload obj = new overload();
  6. obj.compare(31,20);
  7. obj.compare('j','s');
  8. obj.compare("MOM","Dad");
  9. }
  10. }
  11.  
  12. class overload
  13. {
  14. void compare(int m, int n)
  15. {
  16. if(m>n)
  17. {
  18. System.out.println("m has the greater value : "+m);
  19. }
  20. else
  21. {
  22. System.out.println("n has the greater value : "+n);
  23. }
  24. }
  25. void compare(char p,char q)
  26. {
  27. if(p>q)
  28. {
  29. System.out.println("p has the greater value : "+p);
  30. }
  31. else
  32. {
  33. System.out.println("q has the greater value : "+q);
  34. }
  35. }
  36.  
  37. void compare(String s1, String s2)
  38. {
  39. if ( s1.compareTo(s2) < 0)
  40. {
  41. System.out.println("First string is greater than second.");
  42. }
  43. else
  44. {
  45. System.out.println("First string is smaller than second.");
  46. }
  47. }
  48.  
  49. }
Success #stdin #stdout 0.07s 2841600KB
stdin
Standard input is empty
stdout
m has the greater value : 31
q has the greater value : s
First string is smaller than second.