How to use valueOf() to get the relevant Number Object holding the value of the argument passed in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        Double d = Double.valueOf(34); // valueOf(int i)
        Float f = Float.valueOf("9.81"); // valueOf(String s)              
        Integer i = Integer.valueOf("15", 16); // valueOf(String s, int radix)

        System.out.println(d);
        System.out.println(f);
        System.out.println(i);
    }
}
 
/*
run:

34.0
9.81
21
 
*/

 



answered Sep 6, 2016 by avibootz
...