Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

String..  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could anyone let me know how to check whether the string is an integer?
Thanks,
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer.parseInt(String)
If the String doesn't represent an integer, the method will throw a NumberFormatException. Otherwise, it returns the value of the int. Similar methods exist in the other numeric wrapper classes as well - Float, Double, Long, etc.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!