source code Double class
package wclasses;
public class SampleDouble {
public static void main(String att[])
{
// constructors
Double d1= new Double(10.5);
Double dd=new Double(10.5d);
Double ds=new Double("10.5");
// wrapper to primitive
double pd1=d1.doubleValue();
System.out.println(pd1);
//primitive to string
String s1=d1.toString();
String s2=Double.toString(10.57f);
System.out.println(s1);
System.out.println(s2);
//String to primitive
double pd2=Double.parseDouble(s2);
System.out.println(pd2);
//String to wrapper object
Double d2= new Double("10");
Double d3=Double.valueOf("100");
System.out.println(d2);
System.out.println(d3);
//wrapper to string
String s3=d3.toString();
}
}
output:
10.5
10.5
10.569999694824219
10.569999694824219
10.0
100.0
0 comments:
Post a Comment