How to convert String into primitive datatype.

Answer Posted / vikki

using parseInt() method for example

//String to primitive types
int iVal = Integer.parseInt(str);
long lVal = Long.parseLong(str);
float fVal = Float.parseFloat(str);
double dVal = Double.parseDouble(str);

Is This Answer Correct ?    32 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between class & object?

558


Which class is the superclass for all the classes?

535


Can we override final method?

571


What about method local inner classes or local inner classes in java?

557


Is empty set an element of empty set?

606






What is a numeric format?

570


What are adapter classes?

601


Which method returns the length of a string?

571


How java uses the string and stringbuffer classes?

516


What is keyword and identifier?

640


What is a treemap in java?

543


What is string pool in java?

565


Explain a situation where finally block will not be executed?

576


What is function overriding and overloading in java?

583


How is final different from finally and finalize?

496