When I use System.out.println(obj.getClass())
it doesn\'t give me any error. From what I understand getClass()
returns a Class type.
Since p
See the code:
787 public void println(Object x) {
788 String s = String.valueOf(x);
789 synchronized (this) {
790 print(s);
791 newLine();
792 }
793 }
Note the String.valueOf(x)
.
Bonus for asking a good question:
632 public void print(String s) {
633 if (s == null) {
634 s = "null";
635 }
636 write(s);
637 }
That's why it prints null
when the object is null :)