fork download
  1. class Ideone {
  2.  
  3. public static void main(String[] args) {
  4. final String s = "s";
  5. final Object o = s;
  6. final String t = foo(s); // will call foo(String)
  7. final Object p = foo(o); // will call foo(Object)
  8. }
  9.  
  10. public static String foo(String s) {
  11. System.out.println("String");
  12. return s;
  13. }
  14.  
  15. public static Object foo(Object o) {
  16. System.out.println("Object");
  17. return o;
  18. }
  19. }
Success #stdin #stdout 0.1s 47212KB
stdin
Standard input is empty
stdout
String
Object