Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI and Strings

 
Graham Robinson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't work out how to take them in, I've had it so it will work out the pounds to kilos, but can't seem to send it down. I've tried a few different strimgs etc, here is the code.


 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use String.equals() method to compare Strings, not ==
eg
 
Murad Iqbal
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. What are you comparing 'name' and 'kilo' with? 'p' and 'k' are empty strings isnt it? So I suggest initialize them with something you would want to compare them with

2. As told earlier, for String comparison use .equals() method from the String class.
 
Graham Robinson
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers, it works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic