This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

string.equals("");  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys. Im sorry if my question will be a little vague and "noob" but i have this problem ive been thinking for 2 hours and im tired,i hope maybe you can help again.
I read a string from the keyboard and i use an if to determine what "word" is it. The if (xx.equals("exit"){ seems to be working fine,but the other two don't.Its so simple i cant think whats going wrong...
 
Sheriff
Posts: 23692
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chester Man wrote:The if (xx.equals("exit"){ seems to be working fine,but the other two don't.


It would help if you described what "don't seem to be working fine" actually means in your environment.
 
Timos Mann
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for fast reply Paul. Well,im not sure i understand your question,but i mean that, what i wanted to do,is read a string, then say if the string is "B" call the getB method(), if it is "knot" the getKnot method,if it is "exit" make the com true so you exit the loop. So if i enter "exit" it leaves the loop,but entering B or knot doesnt work,its like entering wrong text,back to loop start. I dont know if that was your question.
 
Sheriff
Posts: 21450
95
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you get the invalid input message? How about printing what that invalid input is:
 
Timos Mann
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you were right,i should have seen it. i forgot an (int) in the methods within the if... geez. Thanks Paul, i was totaly stuck
 
lowercase baba
Bartender
Posts: 12627
50
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

chester Man wrote:,im not sure i understand your question...


What he means is TellTheDetails. Your original post said (basically) "this case doesn't work". That doesn't tell us much. does the program choke and die? Does it run the wrong block? Does it run the right block but the code in that block is wrong?

the more info you give people, the easier it is for them to help, and the more likely they will help.

 
Timos Mann
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,im sorry Fred you are right. Im just kind of new to java,plus i was really tired. After finding what was wrong i can say for sure there was no way to get help the way i asked it. Thanks for taking the time to answer my thread though!
 
Marshal
Posts: 60069
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never say while (com==false) . . . It's while (!com) . . .

Did you sort your problem out? What did you do? Your last posting leaves us even more confused about what is happening.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!