• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting a string to an int

 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my code for booking a seat I have
availableSeat.getText() < purchaseFlightSeats.getText()
The problem is cant convert int to String but I need to this to compare the number of seats available to the number the client wishes to purchase..
Any Suggestions???
Thanks Lisa
 
Ajit Kumar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
new Integer(string).intValue();
 
Rudy Yeung
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lisa,
You can also use Integer static method without instantiating an Integer object like Integer.parseInt(string).
Rudy
 
Lisa Foster
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much.
Moving right along..
Lisa
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!