• Post Reply Bookmark Topic Watch Topic
  • New Topic

convert string into int  RSS feed

 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there!!!
i have one problem....
i have a string which actually an integer...because it was selected from a string...
eg : i buy 2 cakes
the selected substring is 2(name as select)

i need to compare it...if select is less then 0....then it will instantiate to 0....where it will the gives the output as

i buy 0 cake...

the problem is....i cant do the comparison because 2 is not an integer...its a string.....
can anybody help me solve this problem
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Convert the String to an int and do the comparision
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!