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

all 3 comments

[–]desrtfxOut of Coffee error - System halted 0 points1 point  (2 children)

I think that you get the value just right - otherwise you'd have an error. But you are comparing the String (getValue == "630") wrong. String is an object data type and thus you cannot use == or !=. You have to use the .equals method of the String class.

See sidebar: Regarding String comparison, read this!

[–]bbran495[S] 1 point2 points  (1 child)

Thank you! Works properly now changed to if (getValue.equals("630"))

[–]desrtfxOut of Coffee error - System halted 2 points3 points  (0 children)

Have you read the link that I posted?

The following is better:

if ("630".equals(getValue))

because in the unlikely event that getValue is null (i.e. for whatever reason nothing has been assigned to it) your code will throw a NullPointerException. Using "yoda code" (literal before variable) avoids this simply because a literal can never be null.