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 are encapsulation, inheritance and polymorphism?

708


What are different type of exceptions in java?

721


How to create a fecelet view?

766


What are the different types of garbage collectors in java?

788


who can i handle multiple client in RMI

1651


Can we override constructors?

756


How does arraylist size increase in java?

761


Is 0 a prime number?

732


What is finalize()?

865


Why hashcode is used in java?

674


When should the method invokelater() be used?

754


what do you understand by synchronization? Or what is synchronization and why is it important? Or describe synchronization in respect to multithreading? Or what is synchronization? : Java thread

689


Which collection is ordered in java?

725


How do you include a string in java?

734


How can we find the actual size of an object on the heap?

1052