Having trouble with a small example from school
Posted
by
Kalec
on Stack Overflow
See other posts from Stack Overflow
or by Kalec
Published on 2012-10-20T10:47:16Z
Indexed on
2012/10/20
11:01 UTC
Read the original article
Hit count: 340
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.
© Stack Overflow or respective owner