|
-
September 19th, 2000, 07:20 PM
#1
How to concert String to int?
How to concert String to int? I've tried to use parseInt() and valueOf(), but it can not work.
thank you!
Best Regards,
Kevin Shen
Best Regards,
Kevin Shen
-
September 20th, 2000, 01:30 AM
#2
Re: How to concert String to int?
Hi Kevin,
may be you used parseInt () in a wrong way.
Try this (I am sure this works, I use this code - if not, contact me again!!!):
Integer aInt = null;
int tmp = aInt.parseInt(aString);
Another possibility (I use this as well) is following:
String wrapperString = "2";
Integer wrapperInt;
int wrapperIntResult;
wrapperInt = Integer.valueOf(wrapperString);
wrapperIntResult = wrapperInt.intValue();
Andi
-
September 20th, 2000, 01:32 AM
#3
Re: How to concert String to int?
Try
String str = "12345";
Integer ii = new Integer(str);
int i = ii.intValue();
Timo
-
September 21st, 2000, 12:35 AM
#4
Re: How to concert String to int?
Integer.parseInt("1243");//returns an int
Float.parseFloat("12.23");//returns a float
Byte.parseByte("12");//returns a byte
Long.parseLong("12543241");//returns a long
Double.parseDouble("12355.3");//returns a double
All of the "wrapper" classes have the equivalent method except for Character.
Phill.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|