Java Double
public class
JavaDoubleExample
{
public static void
main(String[] args)
{
double d = 10.10;
Double dObj1 = new
Double(d);
System.out.println(dObj1);
Double dObj3 = new
Double("25.34");
System.out.println(dObj3);
}
}
Java Double is
Infinite
public class
JavaDoubleIsInfiniteExample
{
public static void
main(String[] args)
{
double d = (double) 4/0;
boolean b1 =
Double.isInfinite(d);
System.out.println(b1);
Double dObj = new
Double(d);
boolean b2 =
dObj.isInfinite();
System.out.println(b2);
}
}
Java Double is
Na N method
public class
JavaDoubleIsNaNExample
{
public static void
main(String[] args)
{
double d = Math.sqrt(-10);
boolean b1 =
Double.isNaN(d);
System.out.println(b1);
Double dObj = new
Double(d);
boolean b2 = dObj.isNaN();
System.out.println(b2);
}
}
Convert Java
Float Object to String Object
public class
JavaFloatToStringExample
{
public static void
main(String[] args)
{
Float fObj = new
Float(10.25);
String str =
fObj.toString();
System.out.println("Float
converted to String as " + str);
}
}
Convert Java
Float to Numeric Primitive Data Types
public class
JavaFloatToNumericPrimitiveTypesExample
{
public static void
main(String[] args)
{
Float fObj = new Float("10.50");
byte b = fObj.byteValue();
System.out.println(b);
short s =
fObj.shortValue();
System.out.println(s);
int i = fObj.intValue();
System.out.println(i);
float f =
fObj.floatValue();
System.out.println(f);
double d =
fObj.doubleValue();
System.out.println(d);
}
}
Convert Java
String to Float Object
public class
JavaStringToFloatExample
{
public static void
main(String[] args)
{
Float fObj1 = new
Float("100.564");
System.out.println(fObj1);
String str1 =
"100.476";
Float fObj2 =
Float.valueOf(str1);
System.out.println(fObj2);
String str2 =
"76.39";
float f =
Float.parseFloat(str2);
System.out.println(f);
}
}
No comments:
Post a Comment