Saturday, March 12, 2016

Java Does Not Equal (!=) Not Working?





Here is my code snippet:



public void joinRoom(String room) throws MulticasterJoinException {
String statusCheck = this.transmit("room", "join", room + "," + this.groupMax + "," + this.uniqueID);

if (statusCheck != "success") {
throw new MulticasterJoinException(statusCheck, this.PAppletRef);
}
}



However for some reason, if (statusCheck != "success") is returning false, and thereby throwing the MulticasterJoinException.


Answer



if (!"success".equals(statusCheck))

No comments:

Post a Comment