• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String to Integer

 
Gabriel Collet
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a string with two charecters that are numbers. I need to change this string into an integer. How do I do it?

Please, can anyone give me a hand?

Thanks
[ February 17, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to yell in your topics. Putting topics in all caps is equivalent to yelling. Please use proper case or lower case in your topics.

I am going to edit your two threads to have Proper case topics.

Thanks

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"JG GA"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Alan Walker
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the static method Integer.parseInt(String), which returns an integer or throws a NumberFormatException.
 
Kirk Bateman
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont forget the input to Integer.parserInt(String) is meant to be JUST the number you want to parse not the whole string... otherwise you'll get the NumberFormatException.

Cheers

Kirk
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic