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

How does class forname work in java?

475


What does the exclamation mark mean in java?

586


What is <> used for in java?

663


Is main a keyword in java?

531


How are observer and observable used in java programming?

537






Why is string class considered immutable?

593


What an i/o filter?

558


what is comparable and comparator interface?

570


Describe the process as to how substring() methodology mechanisms in java.

554


What is the difference between static and global variables and also define what are volatile variables?

547


This abstract class is correct ? abstract class A { public abstract void Disp(); public abstract void B() { } public absract virtual C() { } }

555


What is static data type in java?

534


What Is Query Throttling in java?

555


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

573


What is derived datatype?

621