• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting from String to int

 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to convert from a String to do numeric sorting. Below is what I would like to accomplish in what I think should work. But I get an error message in NetBeans saying "inconvertible types. Required: int. Found Java.lang.String" why won't this convert the string to an integer? How do I accomplish this?

Thanks for your help.


 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the Integer.parseInt() method.
 
Tapas Chand
Ranch Hand
Posts: 554
8
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bud
In java there is a parseInt method of Integer class by which you can convert String to integer
Your code should be like this
 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic