• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

problem with int and for statement

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i, i may be one of the stupidest people i know
 
lowercase baba
Posts: 13069
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lolololol
 
Lookout! Runaway whale! Hide behind this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic