![]() |
|||||
|
return to computer science and java Section 1: Declarations and Access Control Section 2: Flow Control, Assertions, and Exception Handling Section 4: Language Fundamentals Section 5: Operators and Assignments Section 6: Overloading, Overriding, Runtime Type and Object Orientation Section 8: Fundamental Classes in the JAVA.LANG Package |
The
|
||||
| e.g. | int i = 321; Integer wrappedInt = new Integer(i);, or new Integer(321)or Integer wrappedInt = new Integer("321"); |
byteValue(), shortValue(), intValue(), longValue(), floatValue(), doubleValue(), called by any wrapped number, returns a byte, short, int, long, float, double primitive respectively
characterInstance.charValue() returns a char, and booleanInstance.booleanValue() returns a boolean
valueOf(String s)
static method for all wrapper classes except Character
Integer wrappedInt = Integer.valueOf("321");
static Byte|Short|Integer|Long|Float|Double.parseByte|Short|Int|Long|Float|Double(String s)
static method
- returns the primitive
- e.g.
int i = Integer.parseInt("321");
- can throw a
NumberFormatException
getBoolean|Integer|Long(String name_of_system_property)
static method
- returns the wrapped value
- overloaded
getInteger|Long(String name_of_system_property, int|long default_value)
- all have good
toString() and equals(Object that) methods
static Integer|Long.toBinary|Octal|HexString(int|long)
java.lang.String
String s = "text"; - kept in pool of strings (so '==' seems to work on strings created in this way)
String s = new String("text"); - makes a copy of the string during run-time (so new creates a unique copy, can put back in pool with s.intern();)
char charAt(int i)
int indexOf(char c) and int lastIndexOf(char c)
boolean startsWith(String that) and boolean endsWith(String that)
boolean equals(String that), boolean equalsIgnoreCase(String that) and int compareTo(String that)
String substring(int start_index), String substring(int start_index, int end_index, String trim(), String toUpper|LowerCase(), String concat(String that)
int length()
String toString() - returns the executing object