This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes problem with int and for statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem with int and for statement" Watch "problem with int and for statement" New topic
Author

problem with int and for statement

levi sleight
Greenhorn

Joined: Sep 19, 2012
Posts: 19
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

Joined: Jun 19, 2010
Posts: 825
    
    5

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.


The quieter you are, the more you are able to hear.
levi sleight
Greenhorn

Joined: Sep 19, 2012
Posts: 19
i, i may be one of the stupidest people i know
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11152
    
  16

you and probably half the people here have made that exact same mistake.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
levi sleight
Greenhorn

Joined: Sep 19, 2012
Posts: 19
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

Joined: Aug 11, 2012
Posts: 370
    
    1

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

Joined: Jun 19, 2010
Posts: 825
    
    5

Can't help but notice that this topic has nothing to do with for statement.
levi sleight
Greenhorn

Joined: Sep 19, 2012
Posts: 19
lolololol
 
Don't get me started about those stupid light bulbs.
 
subject: problem with int and for statement
 
Similar Threads
Bank program class or switch problem
Stacks
read an expression and solve it...
using user input to pick Object to be used in case/Switch
[HELP]Trying to make a decision cmd adventure! How to branch decisions? NEED HELP AGAIN :S! NOT done