• Post Reply Bookmark Topic Watch Topic
  • New Topic

keyword if not working sometimes  RSS feed

 
peter m hayward
Ranch Hand
Posts: 105
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very simple peice of code that work some time and then at other it fails

i have use system.out.println() to print out the variables which in both test cases are the same and yet the "if" fails



here is the print out the first time it worked  and chosen = book 1
the second time nothing happens

sizeOfWordBeingTested=  6

TargetSize=  10

chosen=  book 1

sizeOfWordBeingTested=  6

TargetSize=  10

is there some about if that causes this problem
 
Carey Brown
Saloon Keeper
Posts: 3309
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not enough code to even begin to answer your question. Where's the print statements? And line 8 is not valid Java syntax.
 
Dave Tolls
Ranch Foreman
Posts: 3056
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first thing I see is that one variable is declared as sizeOfFoundWord and the if statement is testing a variable called sizeOfWordBeingTested .
As Carey says, there's not enough there to figure out what the issue is.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!