Java Boolean
public class
JavaBooleanExample
{
public static void
main(String[] args)
{
Boolean blnObj1 = new
Boolean(true);
Boolean blnObj2 = new Boolean("false");
System.out.println(blnObj1);
System.out.println(blnObj2);
}
}
Convert Java
Boolean object to boolean primitive
public class
JavaBooleanTobooleanExample
{
public static void
main(String[] args)
{
Boolean blnObj = new
Boolean("true");
boolean b =
blnObj.booleanValue();
System.out.println(b);
}
}
Convert Java
boolean Primitive to Boolean object
public class
BooleanPrimitiveToBooleanObjectExample
{
public static void
main(String[] args)
{
boolean b = true;
Boolean blnObj1 = new Boolean(b);
Boolean blnObj2 =
Boolean.valueOf(b);
}
}
Convert Byte
object to String object
public class
ByteToStringExample
{
public static void
main(String[] args)
{
Byte bObj = new
Byte("10");
String str =
bObj.toString();
System.out.println("Byte
converted to String as " + str);
}
}
Convert Byte to
numeric primitive data types
public class
ByteToNumericPrimitiveTypesExample
{
public static void
main(String[] args)
{
Byte bObj = new
Byte("10");
byte b = bObj.byteValue();
System.out.println(b);
short s =
bObj.shortValue();
System.out.println(s);
int i = bObj.intValue();
System.out.println(i);
float f =
bObj.floatValue();
System.out.println(f);
double d =
bObj.doubleValue();
System.out.println(d);
long l = bObj.longValue();
System.out.println(l);
}
}
Convert Java
String to Byte
public class
StringToByteExample
{
public static void
main(String[] args)
{
Byte bObj1 = new
Byte("100");
System.out.println(bObj1);
String str =
"100";
Byte bObj2 =
Byte.valueOf(str);
System.out.println(bObj2);
}
}
Convert String
to primitive byte
public class
StringToPrimitiveByteExample
{
public static void
main(String[] args)
{
String str = new
String("10");
byte b =
Byte.parseByte(str);
System.out.println(b);
}
}
No comments:
Post a Comment