Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
convert string to primitive integer
chinna talluru
Greenhorn
Posts: 24
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
anyone helps me how to convert
String
data type primitive integer
data type
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public static int stringToInt(String s) { try { return Integer.parseInt(s); } catch (NumberFormatException e) { return 0; // or do your thing. } }
Edwin Dalorzo
Ranch Hand
Posts: 961
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Another options could be:
int i = Integer.valueOf("100").intValue();
Or simply, if you are using JDK 1.5
int i = Integer.valueOf("100");
Another way could be:
NumberFormat nf = NumberFormat.getIntegerInstance(); int i = nf.parse("100").intValue();
[ October 09, 2006: Message edited by: Edwin Dalorzo ]
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
casting confusion
Wrapper's String Constructor
polymorphism and casting in java??????
int to float conversion
Can we do this?
More...