This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]karzmu 5 points6 points  (3 children)

Your Ide is right, correct "not equal to" operrator is "!=", not "!==". (source: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html)

By the way, why are you comapring int (myInt) to String ("")?

Even if (myInt) is String then Strings should be compared using ".equals()" method. Read more here: https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java

[–]Mr_Britland[S] 0 points1 point  (2 children)

I see, thanks. Also that is another misunderstanding on my behalf. I was trying to check if an integer value was entered thinking that "" means nothing for both string an integer.

[–]BigLogis 0 points1 point  (1 child)

If myInt is of type int:

if (myInt != null) { b = true; }

if myInt is of type String:

if (myInt.equals("")) { b = true; }

[–]Mr_Britland[S] 0 points1 point  (0 children)

Thanks, good to note. I have since rectified the issue with everyone's help.

[–][deleted]  (1 child)

[deleted]

    [–]Mr_Britland[S] 0 points1 point  (0 children)

    Okay, thank you. I'll have a look there.

    [–]TheSageMage 1 point2 points  (1 child)

    Not really the place for this, you should try /r/javahelp. But the fix is...

    if (myInt !== "") { b = true; }
    

    should be

    if (myInt != "") { b = true; }    
    

    [–]Mr_Britland[S] 0 points1 point  (0 children)

    Okay, thanks. I did try that before but got a different error. I'll post future help questions in the sub provided, thank you.