



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the methods available for the java primitive type wrappers of number (byte, short, integer, long) and character types. The methods include value conversion, parsing strings to numbers, and comparison. The document also includes examples and explanations of each method.
Typology: Slides
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























211
byte byteValue( ) Returns the value of the invoking object as a byte.
int compareTo(Byte b) Compares the numerical value of the invoking object with that of b. Returns 0 if the values are equal. Returns a negative value if the invoking object has a lower value. Returns a positive value if the invoking object has a greater value. int compareTo(Object obj) Operates identically to compareTo(Byte) if obj is of class Byte. Otherwise, throws a ClassCastException.
212
static Byte decode(String str) throws NumberFormatException
Returns a Byte object that contains the value specified by the string in str. double doubleValue( ) Returns the value of the invoking object as a double.
boolean equals(Object ByteObj) Returns true if the invoking Byte object is equivalent to ByteObj. Otherwise, it returns false. float floatValue( ) Returns the value of the invokingobject as a float.
int hashCode( ) Returns the hash code for the invoking object.
214
short shortValue( ) Returns the value of the invoking object as a short.
String toString( ) Returns a string that contains the decimal equivalent of the invoking object static String toString(byte num) Returns a string that contains the decimal equivalent of num.
static Byte valueOf(String str) throws NumberFormatException
Returns a Byte object that contains the value specified by the string in str. static Byte valueOf(String str, int radix) throws NumberFormatException
Returns a Byte object that contains the value specified by the string in str using the specified radix.
215
byte byteValue( ) Returns the value of the invoking object as a short.
int compareTo(Short s ) Compares the numerical value of the invoking object with that of b. Returns 0 if the values are equal. Returns a negative value if the invoking object has a lower value. Returns a positive value if the invoking object has a greater value. int compareTo(Object obj) Operates identically to compareTo( Short ) if obj is of class Short. Otherwise, throws a ClassCastException.
217
int intValue( ) Returns the value of the invoking object as an int.
long longValue() Returns the value of the invoking object as a long.
static short parseShort (String str) throws NumberFormatException
Returns the short equivalent of the number contained in the string specified by str using radix 10. static short parseShort (String str, int radix) throws NumberFormatException
Returns the short equivalent of the number contained in the string specified by str using the specified radix
218
short shortValue( ) Returns the value of the invoking object as a short.
String toString( ) Returns a string that contains the decimal equivalent of the invoking object static String toString(short num) Returns a string that contains the decimal equivalent of num.
static Short valueOf(String str) throws NumberFormatException
Returns a Short object that contains the value specified by the string in str. static Short valueOf(String str,int radix) throws NumberFormatException
Returns a Short object that contains the value specified by the string in str using the specified radix.
220
static Integer decode(String str) throws NumberFormatException
Returns a Integer object that contains the value specified by the string in str. double doubleValue( ) Returns the value of the invoking object as a double.
boolean equals(Object Integer Obj) Returns true if the invoking Short object is equivalent to Integer Obj. Otherwise, it returns false. float floatValue( ) Returns the value of the invokingobject as a float.
int hashCode( ) Returns the hash code for the invoking object.
static int lowestOneBit(int num)
static Integer decode(String str) throws NumberFormatException
Returns a Integer object that contains the value specified by the string in str. double doubleValue( ) Returns the value of the invoking object as a double.
boolean equals(Object Integer Obj) Returns true if the invoking Short object is equivalent to Integer Obj. Otherwise, it returns false. float floatValue( ) Returns the value of the invokingobject as a float.
int hashCode( ) Returns the hash code for the invoking object.
static int lowestOneBit(int num) Determines the number of high-order zero bits that precede the first high-order set bit in num.If num is zero,32 is returned.
221
int intValue( ) Returns the value of the invoking object as an int.
static Integer getInteger(String propertyName)
Returns the value associated with the environmental property specified by propertyName. A null is returned on failure.
static Integer getInteger(String propertyName, int default)
Returns the value associated with the environmental property specified by propertyName. The value of default is returned on failure.
long longValue() Returns the value of the invoking object as a long.
static int parseInt (String str) throws NumberFormatException
Returns the integer equivalent of the number contained in the string specified by str using radix 10.
static int parseInt (String str, int radix) throws NumberFormatException
Returns the integer equivalent of the number contained in the string specified by str using the specified radix
223
byte byteValue( ) Returns the value of the invoking object as a short.
int compareTo( Long l ) Compares the numerical value of the invoking object with that of b. Returns 0 if the values are equal. Returns a negative value if the invoking object has a lower value. Returns a positive value if the invoking object has a greater value. int compareTo(Object obj) Operates identically to compareTo(Long) if obj is of class Long. Otherwise, throws a ClassCastException. static int bitCount(int num) Returns the number of set bits in num.
224
static Integer decode(String str) throws NumberFormatException
Returns a Integer object that contains the value specified by the string in str. double doubleValue( ) Returns the value of the invoking object as a double.
boolean equals(Object Integer Obj) Returns true if the invoking Short object is equivalent to Integer Obj. Otherwise, it returns false. float floatValue( ) Returns the value of the invokingobject as a float.
int hashCode( ) Returns the hash code for the invoking object.
static int lowestOneBit(int num)
static Long decode(String str) throws NumberFormatException
Returns a Long object that contains the value specified by the string in str. double doubleValue( ) Returns the value of the invoking object as a double.
boolean equals(Object Long Obj) Returns true if the invoking Short object is equivalent to Long Obj. Otherwise, it returns false. float floatValue( ) Returns the value of the invokingobject as a float.
int hashCode( ) Returns the hash code for the invoking object.
static long lowestOneBit(long num) Determines the number of high-order zero bits that precede the first high-order set bit in num.If num is zero,32 is returned.
226
short shortValue( ) Returns the value of the invoking object as a short.
String toString( ) Returns a string that contains the decimal equivalent of the invoking object static String toString(short num) Returns a string that contains the decimal equivalent of num.
static Integer valueOf(String str) throws NumberFormatException
Returns a Integer object that contains the value specified by the string in str. static Integer valueOf(String str,int radix) throws NumberFormatException
Returns a Integer object that contains the value specified by the string in str using the specified radix.
227
This program sums a list of numbers entered by the user. It converts the string representation of each number into an int using parseInt()
229
230