Java.lang package contains the classes that are fundamental to the design of the Java programming language. Java.lang.Character Class Java.lang.Float Class Java.lang.Integer Class Java.lang.Character Class The java.lang.Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char. Class declaration Code: public final class Character extends Object implements Serializable, Comparable<Character> Class constructors Character(char value) - Newly allocated Character object is created which represents the specified char value. Class methods static int charCount(int codePoint) - It returns the number of char values needed to represent the specified character. static int codePointAt(char[] a, int index) - Code point at the given index of the char array is returned. static int codePointAt(CharSequence seq, int index) - Code point at the given index of the CharSequence is returned. int compareTo(Character anotherCharacter) - Two Character objects are compared numerically. static int getNumericValue(char ch) - The int value represented by the specified Unicode character is returned. static boolean isLowerCase(char ch) - Determines whether the specified character is a lowercase character or not. static boolean isUpperCase(char ch) - Determines whether the specified character is an uppercase character or not. static boolean isWhitespace(char ch) - Determines whether the specified character is white space according to Java. static char toLowerCase(char ch) - Character argument is converted to lowercase using case mapping information from the UnicodeData file. String toString() - String object representing this Character's value is returned. static char toUpperCase(char ch) - Character argument is converted to uppercase using case mapping information from the UnicodeData file. static Character valueOf(char c) - Character instance representing the specified char value is returned. Example Code: public class CharacterDemo { public static void main(String[] args) { Character c1, c2; c1 = new Character('v'); c2 = new Character('d'); int result; // compares c2 with c1 result = c1.compareTo(c2); if( result == 0 ){ System.out.println("Both charcters are equal."); } else if( result > 0 ){ System.out.println("First character is greater than Second."); } else if( result < 0 ){ System.out.println("Second character is greaterthan First."); } } } Output Java.lang.Float Class The java.lang.Float class wraps a value of primitive type float in an object. An object of type float contains a single field whose type is float. Class declaration Code: public final class Float extends Number implements Comparable<Float> Class constructors Float(double value) - Creates a new float object which represents the argument converted to type float. Float(float value) - Creates a new float object which represents the primitive float argument. Float(String s) - Creates a new float object which represents the floating-point value of type float represented by the string. Class methods static int compare(float f1, float f2) - Two specified float values are compared for equality double doubleValue() - Double value of the Float object is returned. float floatValue() - Float value of the Float object is returned. int intValue() - Value of the Float as an int is returned (by casting to type int). long longValue() - Value of the Float as a long is returned (by casting to type long). static float parseFloat(String s) - This method returns a new float initialized to the value represented by the specified string. short shortValue() - Value of this Float as a short is returned (by casting to a short). String toString() - String representation of this Float object is returned. static Float valueOf(float f) - Float instance representing the specified float value is returned. static Float valueOf(String s) - Float object holding the float value represented by the argument string is returned. Example Code: class FloatDemo { public static void main(String dt[]) { float a,b; double mul=0; try{ a= Float.parseFloat(dt[0]); b= Float.parseFloat(dt[1]); mul= a*b; System.out.println("Result is="+mul); } catch (NumberFormatException e) { System.out.println(e); } catch (ArithmeticException e) { System.out.println(e); } catch(ArrayIndexOutOfBoundsException e) { System.out.println(e); } catch(Exception e) { System.out.println(e); } finally { System.out.println("Thank you"); } } } Output Java.lang.Integer Class The java.lang.Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field of int type. Class declaration Code: public final class Integer extends Number implements Comparable<Integer> Class constructors Integer(int value) - Newly allocated Integer object is constructed which represents the specified int value. Integer(String s) - Newly allocated Integer object is constructed which represents the int value indicated by the string parameter. Class methods double doubleValue() - Value of this Integer is returned as a double. float floatValue() - Value of this Integer is returned as a float. static Integer getInteger(String nm) - Integer value of the system property with the specified name is determined. int intValue() - Value of this Integer is returned as int. long longValue() - Value of this Integer is returned as a long. static int parseInt(String s) - The string argument is parsed as a signed decimal integer. String toString() - String object is returned representing this Integer's value. static String toString(int i) - String object is returned representing the specified integer. static Integer valueOf(int i) - Integer instance is returned representing the specified int value. static Integer valueOf(String s) - Integer object is returned holding the value of the specified String. Example Code: class ExceptionDemo { public static void main(String dt[]) { int a,b, div=0; try { a= Integer.parseInt(dt[0]); b= Integer.parseInt(dt[1]); div= a/b; System.out.println("div is="+div); } catch (NumberFormatException e) { System.out.println(e); } catch (ArithmeticException e) { System.out.println(e); } catch(ArrayIndexOutOfBoundsException e) { System.out.println(e); } catch(Exception e) { System.out.println(e); } finally { System.out.println("Thank you"); } } } Output