List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:Main.java
public static void main(String[] args) { System.out.println(Double.valueOf("1.234")); }
From source file:Main.java
public static void main(String[] args) throws Exception { Double d = Double.valueOf("0.9D").doubleValue(); }
From source file:Main.java
public static void main(String[] args) { System.out.println("Value = " + Double.valueOf(3.5d)); }
From source file:MainClass.java
public static void main(String args[]) { double degrees = Double.valueOf("10.234").doubleValue(); System.out.println(degrees);/* w w w . jav a 2s. co m*/ }
From source file:Main.java
public static void main(String[] args) { Double dObj1 = new Double("100.564"); System.out.println(dObj1);//ww w .j av a 2 s.c o m Double dObj2 = Double.valueOf("10.6"); System.out.println(dObj2); double d = Double.parseDouble("76.39"); System.out.println(d); }
From source file:SquareClient.java
public static void main(String args[]) throws Exception { String server = args[0];//from w w w . j a v a 2s. c o m int port = Integer.parseInt(args[1]); double value = Double.valueOf(args[2]).doubleValue(); Socket s = new Socket(server, port); OutputStream os = s.getOutputStream(); DataOutputStream dos = new DataOutputStream(os); dos.writeDouble(value); InputStream is = s.getInputStream(); DataInputStream dis = new DataInputStream(is); value = dis.readDouble(); System.out.println(value); s.close(); }
From source file:Main.java
public static void main(String args[]) throws Exception { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); while (true) { System.out.print("Radius? "); String str = br.readLine(); double radius; try {//w ww.j a va 2 s . c o m radius = Double.valueOf(str).doubleValue(); } catch (NumberFormatException nfe) { System.out.println("Incorrect format!"); continue; } if (radius <= 0) { System.out.println("Radius must be positive!"); continue; } System.out.println("radius " + radius); return; } }
From source file:MainClass.java
public static void main(String args[]) { Boolean bool = Boolean.valueOf("true"); Character c = new Character('c'); Byte b = Byte.valueOf("12"); Short s = Short.valueOf("2"); Integer i = Integer.valueOf("13245"); Long l = Long.valueOf("12341234"); Float f = Float.valueOf("11234.1234"); Double d = Double.valueOf("43213241234.123412341234"); System.out.println(bool);//www . j a va 2s .c o m System.out.println(c); System.out.println(b); System.out.println(s); System.out.println(i); System.out.println(l); System.out.println(f); System.out.println(d); }
From source file:Main.java
public static void main(String[] args) { Integer intObj = Integer.valueOf(100); // Gets byte from Integer byte b = intObj.byteValue(); // Gets double from Integer double dd = intObj.doubleValue(); System.out.println("intObj = " + intObj); System.out.println("byte from intObj = " + b); System.out.println("double from intObj = " + dd); // Creates a Double object Double doubleObj = Double.valueOf("123.45"); // Gets different types of primitive values from Double double d = doubleObj.doubleValue(); float f = doubleObj.floatValue(); int i = doubleObj.intValue(); long l = doubleObj.longValue(); System.out.println("doubleObj = " + doubleObj); System.out.println("double from doubleObj = " + d); System.out.println("float from doubleObj = " + f); System.out.println("int from doubleObj = " + i); System.out.println("long from doubleObj = " + l); }
From source file:MainClass.java
public static void main(String args[]) { try {/* w w w . j a va2s . c om*/ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); while (true) { System.out.print("Radius? "); String str = br.readLine(); double radius; try { radius = Double.valueOf(str).doubleValue(); } catch (NumberFormatException nfe) { System.out.println("Incorrect format!"); continue; } if (radius <= 0) { System.out.println("Radius must be positive!"); continue; } double area = Math.PI * radius * radius; System.out.println("Area is " + area); return; } } catch (Exception e) { e.printStackTrace(); } }