Having trouble with a small example from school
- by Kalec
The example is from a course, it's for comparing two objects in java:
public class Complex {
...
public boolean equals (Object obj) {
if (obj instanceof Complex) { // if obj is "Complex" (complex number)
Complex c = (Complex) obj // No idea
return (real == c.real) && (imag == c.imag);
// I'm guessing real means [this].real
}
return false;
}
}
So, my question is: "what does this: Complex c = (Complex) obj actually mean" ?
Also I've worked with python and c++, java is new for me.