Post

@EclipseJavaIDE @java Unsure if toString on a String is required to return same object. Alters the outcome if it could, say, return a stack-allocated value instead...
Richfield, MN 🇺🇸 English

@EclipseJavaIDE I think it throws a NPE.
"ABC".toString() returns the same value. "ABC"=="ABC" is true, because String cache.
b is true. So... NullPointerException on Y.equals(...) (must be Y == null to be safe)
if B = false, the short circuit logic would prevented NPE.
English

@EclipseJavaIDE False. No NP error as right side to && won't execute
English

@EclipseJavaIDE @jSparrowpicks typical sample of how NOT to write Java programs and produce code smells and decrease readability within a few lines. Totally irrelevant what the output of the program would be, the output of the programmer is major reason to rethink further usability ...
English

@EclipseJavaIDE @java I'm guessing false, since && is lazy evaluated
English

@EclipseJavaIDE Depends on Java version, Java < 7 → false, Java >= 7 → NPE.
Also your variables naming doesn't correspond to Eclipse Coding Conventions...
English

@EclipseJavaIDE @java Null pointer Exception....since function called on Y
English

@EclipseJavaIDE @java NullPointerException will be thrown at the runtime because Y is pointing to null
English

@EclipseJavaIDE From Object.equals() java docs:
"For any non-null reference value x, x.equals(null) should return false."
and since Y is null ... NPE exception is thrown. Would have been evaluated to false if Y was initialized.
English

@EclipseJavaIDE False. toString returns a new String instance. The == is comparing references of X and "ABC".toString(). The NPE never is throwed.
English
























