Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

If statements not working

 
Stephen Black
Ranch Hand
Posts: 52
1
Chrome MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 if's in a row and the variable PTpe is tested against the values 1, 2 and 3 (in that order)
so it should choose the if statement with the appropriate value

However it ALLWAYS NO MATTER WHAT chosses ALL the if statements even thought it is not possible for the if test to be true with all 3
I will attach a picture that demonstrates everything
How could this be?
A bigger image

 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at your second and third if statements (lines 14 and 19). They both have a character that they shouldn't have.
 
Stephen Black
Ranch Hand
Posts: 52
1
Chrome MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok that was a STUPID mistake for me to make (I said as I slapped myself in the head)
Thanks for your help

Matthew Brown wrote:Have a look at your second and third if statements (lines 14 and 19). They both have a character that they shouldn't have.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a stupid mistake. Everybody makes that mistake when they are beginning.
 
Stephen Black
Ranch Hand
Posts: 52
1
Chrome MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future please post the code in code tags rather than posting an image which is not searchable.
 
Rusty Auttenberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did this 3 weeks ago, after 8 hours straight of hair pulling and head bashing I changed the if statement to hit launch, and it still did it. That is when I saw that ... ... semicolon.

I feel much less stupid after seeing your post, I truly hope you spent less time looking for the problem than I did.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic