Converting to and from a String - Java Language Basics

Java examples for Language Basics:String

Description

Converting to and from a String

Demo Code

 
public class Main {
     //from  w  ww .j a  v  a2  s  .com
    public static void main (String[] args) {
        double pi;
        String strval;
 
        pi = Double.parseDouble("3.14");
        System.out.println(strval = String.valueOf(pi));
        System.out.println(Double.toString(pi));
    }
     
}

Result


Related Tutorials