Wednesday, 16 August 2017

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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...