Guest User

Untitled

a guest
Jan 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public void m1(Integer f) {
  2. ...
  3. }
  4.  
  5. public void m1(Float f) {
  6. ...
  7. }
  8.  
  9. public void main() {
  10. m1(null); // error: the method m1(Integer) is ambiguous for the type Main
  11. m1((Integer) null); // success
  12. }
  13.  
  14. Integer i = null;
  15. Object o1 = (Object) i;
  16. Float f = null;
  17. Object o2 = (Object) f;
  18. System.out.println(o1 == o2); // prints true
  19.  
  20. // in short:
  21. System.out.println(((Object) ((Integer) null)) == ((Object) ((Float) null))); // prints true
  22.  
  23. class A {
  24. public static void hello() { System.out.println("Hello World"); }
  25.  
  26. public static void main(String... args) {
  27. A a = null;
  28. a.hello();
  29. System.out.println("a is an A is " + (a instanceof A)); // prints false.
  30. }
  31. }
  32.  
  33. Integer a = null;
  34. Double b = null;
  35.  
  36. m1((Integer) null);
  37.  
  38. Integer i = null;
  39. (Integer)null
Add Comment
Please, Sign In to add comment