So I'm just looking for clarification. I have an equals method that is able to return the instance variable by cv.ch
of a passed object with out a method to return it. How is this so?
public static class Test {
private int v;
private char ch;
public Test(int v, char ch) {
this.v= v;
this.ch= ch;
}
public boolean equals(Object o) {
if ( this == o ) return true;
if ( o == null || this.getClass() != o.getClass() )
return false;
Test cv = (Test) o;
if ( this.v == cv.v && this.ch == cv.ch)
return true;
return false;
}
}
Edit: I rephrased my question so that it is better understood