So far, the variable types we have discussed are called "primitive types" because they represent simple values that have built-in characteristics.
They are fixed elements.
Java also provides a set of "reference types" that include object arrays, strings, and other more complex data structures.
We'll talk more about reference types later when we are using them.
However, it is good to note that Java provides reference "wrapper" types for each primitive type that include manipulative functionality.
Each class contains helper methods that allow you to more easily work with the values.
One of the most useful features provided by the wrapper classes is the ability to easily change from one type to another.
Thus, you can change an integer value to its string representation using something like:
| Boolean |
| final static Boolean FALSE |
Creates a Boolean with a false value |
| final static Boolean MAX_VALUE |
Returns 65535 (this was placed in the boolean class by mistake) |
| final static Boolean MIN_VALUE |
returns 0 (this was placed in the boolean class by mistake) |
| final static Boolean TRUE |
Creates a Boolean with a true value |
| Boolean(String s) |
Creates a Boolean based on the string. true is true. Everything else is false. |
| Boolean (boolean value) |
Creates a Boolean with specified boolean value |
| boolean booleanValue() |
returns the boolean value of the Boolean object |
| boolean equals(Object object) |
Returns true if the objects are equal, false if not. |
| static boolean getBoolean(String s) |
Returns true if s is true. Otherwise it returns false. |
| int hashCode() |
Returns the Boolean's hash code. |
| String toString() |
Returns the string representation of the Boolean. |
| static Boolean valueOf(String s) |
Returns a Boolean representation of the string |
| Character |
| final static int MAX_RASIX |
The maximum radix that can be used in converting a
number to an int (represented as a character). The value is 36. |
| final static int MIN RADIX |
Same as above but returns 2 |
| Character (char value) |
Returns a Character representation of value. |
| char charValue() |
Returns the char representation of the Character object |
| static int digit(char ch, int base) |
Converts ch to int. |
| boolean equals(Object o) |
Tests for equality between the objects. |
| static char forDigit(int digit, int base) |
Returns the char representation of the digit in the specified base. |
| int hashCode() |
Returns the hash code. |
| static boolean isDigit(char c) |
Returns true if the char value is between 0 and 9 |
| static boolean isJavaLetter(char c) |
Returns true if the ch is a alphabet character, $, or _ |
| static boolean isLetter(char c) |
Returns true of the char is a letter |
| static boolean isLetterOrDigit(char c) |
Returns true of the char is a letter or a digit |
| static boolean isLowerCase(char c) |
Returns true of character is lower case. |
| static boolean isSpace(char c) |
Returns true of the character is a space, tab, newline, or return |
| static boolean isUpperCase(char c) |
Returns true of character is upper case. |
| static char toLowerCase(char c) |
Converts a char to lower case. |
| String toString() |
Returns the String representation of the Character |
| static char toUpperCase(char c) |
Returns the Uppercase value of the Character |
| Double |
| final static double MAX_VALUE |
returns the max value |
| final static MIN_VALUE |
Returns the min value |
| final static double NaN |
A double that is not a number |
| final static double NEGATIVE_INFINITY |
-1.0/0.0 |
| final static double POSITIVE_INFINITY |
1.0/0.0 |
| Double(double value) |
Returns a Double representation of the double value. |
| Double (String s) throws NumberFormatExcepion |
Returns a Double representation of the string value. |
| static long double doubleToLongBits(double value) |
Returns the bit representation |
| double doubleValue() |
Returns the double representation of the Double. |
| boolean equals(Object o) |
Tests for equality |
| float floatValue() |
Returns the float representation of the Double |
| int hashCode() |
Returns the hash code |
| int intValue() |
Returns the int representation of the Double. |
| boolean isInfinite() |
Returns true if equal POSITIVE or NEGATIVE infinity |
| static boolean isInfinite(double d) |
Returns true of true. |
| boolean isNaN() |
Returns true if Double is NaN |
| static double longBitsToDouble(long l) |
Double representation of the bits |
| long longValue() |
Returns the long representation of the Double. |
| String toString() |
Returns the String representation of the Double |
| static String toString(double d) |
Converts d to String |
| static Double valueOf(String s) throws NumberFormatException |
Converts String to Double |
| Float |
| final static float MAX_VALUE |
returns the max value |
| final static float MIN_VALUE |
Returns the min value |
| final static float NaN |
A double that is not a number |
| final static float NEGATIVE_INFINITY |
-1.0/0.0 |
| final static float POSITIVE_INFINITY |
1.0/0.0 |
| Float(double value) |
Returns a Float representation of the double value. |
| Float(float value) |
Returns a Float representation of the float value. |
| Float (String s) throws NumberFormatExcepion |
Returns a Float representation of the string value. |
| double doubleValue() |
Returns the double representation of the Float. |
| boolean equals(Object o) |
Tests for equality |
| static int floatToIntBits(float value) |
Returns the bit representation |
| float floatValue() |
Returns the float representation of the Float |
| int hashCode() |
Returns the hash code |
| static float intBitsToFloat(int value) |
Returns the float representation of the int bits |
| int intValue() |
Returns the int representation of the Float. |
| boolean isInfinite() |
Returns true if equal POSITIVE or NEGATIVE infinity |
| static boolean isInfinite(float f) |
Returns true of true. |
| boolean isNaN() |
Returns true if Double is NaN |
| long longValue() |
Returns the long representation of the Float. |
| String toString() |
Returns the String representation of the Float |
| static String toString(float f) |
Converts f to String |
| static Float valueOf(String s) throws NumberFormatException |
Converts String to Float |
| Integer |
| final static int MAX_VALUE |
returns the max value |
| final static int MIN_VALUE |
Returns the min value |
| Integer(int value) |
Returns an Integer representation of the int value. |
| Integer (String s) throws NumberFormatExcepion |
Returns an Integer representation of the String value. |
| double doubleValue() |
Returns the double representation of the Integer. |
| boolean equals(Object o) |
Tests for equality |
| float floatValue() |
Returns the float representation of the Integer |
| static Integer getInteger(String propName) |
Returns System property with given key |
| static Integer getInteger(String propName, int val) |
Returns System property with given key |
| int hashCode() |
Returns the hash code |
| int intValue() |
Returns the int representation of the Integer. |
| long longValue() |
Returns the long representation of the Integer. |
| static int parseInt(String s) throws NumberFormatException |
Returns the int representation of the String |
| String toString() |
Returns the String representation of the Integer |
| static String toString(int i) |
Converts i to String |
| static Integer valueOf(String s) throws NumberFormatException |
Converts String to Integer |
| Long |
| final static long MAX_VALUE |
returns the max value |
| final static long MIN_VALUE |
Returns the min value |
| Long(long value) |
Returns a Long representation of the long value. |
| Long (String s) throws NumberFormatExcepion |
Returns a Long representation of the String value. |
| double doubleValue() |
Returns the double representation of the Long. |
| boolean equals(Object o) |
Tests for equality |
| float floatValue() |
Returns the float representation of the Long |
| static Long getLong(String propName) |
Returns System property with given key |
| static Long getLong(String propName, long val) |
Returns System property with given key |
| int hashCode() |
Returns the hash code |
| int intValue() |
Returns the int representation of the Long. |
| long longValue() |
Returns the long representation of the Long. |
| static long parseLong(String s) throws NumberFormatException |
Returns the long representation of the String |
| String toString() |
Returns the String representation of the Long |
| static String toString(long l) |
Converts l to String |
| static Long valueOf(String s) throws NumberFormatException |
Converts String to Long |
Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena curently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com