Click to See Complete Forum and Search --> : easy question


alanr
September 26th, 2000, 12:08 PM
I know this is easy.. I am coming to java from a long time in C/C++. How do you easily convert a String to an int? sounds easy right? Well, tell me if you know cause I can't figure it out and the MSDN I have doesn't know either. it is a simple atoi() call in C++, but what about java? I am using MS J++.
thanks java people!

vasgaddam
September 26th, 2000, 01:16 PM
Hi, In java we have wrapper classes to do this. If u want to convert to a string to int, do like this...
try
{
String str = "23";
int value = java.lang.Integer.parseInt(str);
System.out.println(val);
}
catch (Exception e) { }

Sreeni
#If this post is valid to u, then dont forget to rate it#