• Post Reply Bookmark Topic Watch Topic
  • New Topic

if else in nested if  RSS feed

 
Anne Saizan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I do not know why I've got this error.
Is this the right way to implement nested if?



the one that in the brown color is the error.it said syntax error in if ,delete this token.
hope you guys can help and give me some ideas to solve the problem.
Thanks
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at line 14. else if what?
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also don't do:

if(something == true)
Just use
if(something)
 
Anne Saizan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yeay!!! thanks guys

now I know my mistakes.
 
Jon Avadis
Ranch Hand
Posts: 49
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:Also don't do:

if(something == true)
Just use
if(something)


Can you explain that one please? I often use



instead of



because to me, this is more readable.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jon Avadis wrote:because to me, this is more readable.

But also more prone to typos. Very easy to write
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also the convention is to do what I advised. Others (and that can include you in a couple of months/years time) might find it harder to read. All programmers read more code then they write.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouter Oet wrote:All GOOD programmers read more code then they write.

fixed that for you...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!