I have code like this:
String stringRef = new String("Java"); // (1)
System.out.println("(2): " + stringRef.getClass()); // (2)
System.out.println("(3): " + stringRef.length()); // (3)
Object objRef = stringRef; // (4)
// System.out.println("(5): " + objRef.length()); // (5) Not OK.
System.out.println("(6): " + objRef.equals("Java"));
Why can I not call length()
in line (5); and for which class will equals()
be called in line (6)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…