Saturday 12 March 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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...