kevin shen
September 19th, 2000, 07:20 PM
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
thank you!
Best Regards,
Kevin Shen
|
Click to See Complete Forum and Search --> : How to concert String to int? kevin shen September 19th, 2000, 07:20 PM 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 Andi September 20th, 2000, 01:30 AM 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 Timo Hahn September 20th, 2000, 01:32 AM Try String str = "12345"; Integer ii = new Integer(str); int i = ii.intValue(); Timo Phill September 21st, 2000, 12:35 AM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |