Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with int and for statement

 
levi sleight
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so im trying to make a simple text adventure. and i have a slight problem. youll see









the problem is that on the 31st line it gives me an error saying "cannot convert int to boolean" ... so i turned it into a boolean, but (i know im a noob) I dont know how to use those so
i changed it back because it said the reverse, on the 43 line, how can i use an int or double in an if statement

 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a difference between an assignment operator (=) and relational equal to operator (==). The first one cannot be used in if statement, so:

is not valid.
 
levi sleight
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i, i may be one of the stupidest people i know
 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you and probably half the people here have made that exact same mistake.
 
levi sleight
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol, i just was about to post another question, because i had another problem with the switch(on a side note, a switch statement inst a loop is it?) and i looked through it 10 times, i felt pretty dumb when i realized that i just didnt have a default with another Chose.nextLine in it, nother question, is this the majority of messups in java? me ripping out my hair over 2 lines?
 
R. Jain
Ranch Hand
Posts: 375
1
Java Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
levi sleight wrote:i looked through it 10 times, i felt pretty dumb when i realized that i just didnt have a default with another Chose.nextLine in it, nother question, is this the majority of messups in java? me ripping out my hair over 2 lines?

And that's how you learn Java.. Unless you pluck 2-3 of your hairs, you will not improve better..
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't help but notice that this topic has nothing to do with for statement.
 
levi sleight
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lolololol
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic