Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below 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);

  }

}

The “ if (statusCheck != "success")”  returns false with the exception MulticasterJoinException. Can anyone tell me why != is not working? 

1 Answer

0 votes
by (19.7k points)

Try the code below:

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

Interested in Java? Check out this Java Certification by Intellipaat.   

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 18, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 18, 2021 in Python by adhiraj (4k points)

Browse Categories

...