aspose file tools*
The moose likes Beginning Java and the fly likes If statements not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "If statements not working" Watch "If statements not working" New topic
Author

If statements not working

Stephen Black
Ranch Hand

Joined: Aug 13, 2009
Posts: 50

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

Joined: Apr 06, 2010
Posts: 4388
    
    8

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

Joined: Aug 13, 2009
Posts: 50

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

Joined: Oct 13, 2005
Posts: 38818
    
  23
Not a stupid mistake. Everybody makes that mistake when they are beginning.
Stephen Black
Ranch Hand

Joined: Aug 13, 2009
Posts: 50

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

In the future please post the code in code tags rather than posting an image which is not searchable.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rusty Auttenberg
Greenhorn

Joined: Apr 07, 2013
Posts: 4
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.
 
Don't get me started about those stupid light bulbs.
 
subject: If statements not working