... in other words: suppose I have 2 lines declared like this:
String one = new String("yay!"); String two = new String("yay!");
these two lines are two different objects, but if I run
if(one.equals(two)) System.out.println("equals() returns true.");
I get: "equals () returns true". This is because the String class overrides the equals () method to implement content level equality. However, I need to access the reference level of equality (for example, implemented in Object) to distinguish the object from the shape of the object. How can i do this?
I tried this:
one.getClass().getSuperclass().equals();
to try to call the equals () method of the String object, but it does not work.
Any tips?
source share