float vs double java code example

Example 1: int to double java

Double d= new Double(i);//first way  
Double d2=Double.valueOf(i);//second way

Example 2: java double to float

double d = getInfoValueNumeric();
float f = (float)d;

Example 3: is double and float the same function in java

Float and double
Double is more precise than float and can store 64 bits, double of the number of bits float can store. ... Float and double function in the same way in all programming languages. For example, in Java, both will throw NumberFormatException with operations where actual numbers are not involved