aspose file tools*
The moose likes Java in General and the fly likes converting from String to int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting from String to int" Watch "converting from String to int" New topic
Author

converting from String to int

Bud Tippins
Ranch Hand

Joined: Jan 28, 2011
Posts: 52
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

Joined: Jun 01, 2010
Posts: 618
Look at the Integer.parseInt() method.
Tapas Chand
Greenhorn

Joined: Dec 29, 2009
Posts: 23
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

Joined: Jan 28, 2011
Posts: 52
Thank you. That worked.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: converting from String to int
 
Similar Threads
I need to put a double into a vector
Sorting on int field of object
Totally Confused
parsing standard input
Hashcode not removing duplicates from set