Primitive Classes

Summary

 

Class List

class java.lang.Boolean (implements java.io.Serializable)

class java.lang.Character (implements java.lang.Comparable, java.io.Serializable)

class java.lang.Number (implements java.io.Serializable)

class java.lang.Byte (implements java.lang.Comparable) 
class java.lang.Double (implements java.lang.Comparable) 
class java.lang.Float (implements java.lang.Comparable) 
class java.lang.Integer (implements java.lang.Comparable) 
class java.lang.Long (implements java.lang.Comparable) 
class java.lang.Short (implements java.lang.Comparable) 

class java.lang.Void

 

System Property

Determines the value of the system property with the specified name.

// for all number classes
static Xxx getXxx(String nm) 
static Xxx getXxx(String nm, xxx val) 
static Xxx getXxx(String nm, Xxx val) 

Note: 'static boolean getBoolean(String name)' is not for system property!

 

Comparison two primitive classes

Compare two Character objects

 

Compare two Number class objects

int compareTo(Xxx anotherXxx) 
int compareTo(Object o) //If the Object is a Xxx, this function behaves like compareTo(Xxx). Otherwise, it throws a ClassCastException

 

 

Conversion among String, primitive classes and primitive variable

Convert primitive class into primitive variable

The xxxValue() returns the value of this primitive object as a primitive variable. such as

boolean booleanValue() //for only class Boolean
char charValue() //for only class Character
xxx xxxValue() // for all number classes

 

Convert String into primitive variable

static xxx parseXxx(String s) // for all number classes.
static xxx parseXxx(String s, int radix) //for class Byte, Short, Integer and Long, except for Float and Double.
static boolean getBoolean(String name)//for only class Boolean

Note: cannot convert String into char or Character.

 

Convert primitive class into String simply by toString() of primitive class

String toString()
static String toString(xxx i) //for all number classes
//for only Integer and Long
static String toBinaryString(xxx i) 
static String toHexString(xxx i) 
static String toOctalString(xxx i) 
static String toString(xxx i, int radix) 

 

Convert String into primitive class simply by constructors or valueOf() of primitive class

static Short valueOf(String s) // for all number classes.
static Short valueOf(String s, int radix) //for class Byte, Short, Integer and Long, except for Float and Double.

Note: cannot convert String into char or Character.

 

Convert encoded String into primitive class simply by decode()

static Xxx decode(String nm) // for only Number class such as Byte, Short, Integer and Long, except for Double and Float.

[-] decimal constant
[-] 0x hex constant
[-] # hex constant
[-] 0 octal constant

 

Convert primitive variable into primitive class simply by constructors of primitive class

 

Convert primitive variable in to String by valueOf() of String

static String valueOf(xxx b) 

 

 

Conversion about characters

 

The Class Void

The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

 

Reference

 

See Also