Beruflich Dokumente
Kultur Dokumente
Each of Java's eight primitive data types has a class dedicated to it. These are known as wrapper classes, because they "wrap" the primitive data type into an object of that class. So, there is an Integer class that holds an int variable, there is a Double class that holds a double variable, and so on. The wrapper classes are part of the java.lang package, which is imported by default into all Java programs.
Wrapper classes allow primitive data types to be accessed as objects. They are one per primitive type: Boolean, Byte, Character, Double, Float, Integer, Long and Short. Wrapper classes make the primitive type data to act as objects.
Class Character
The 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.
isLetter()
Determines whether the specified char value is a letter.
Syntax:
boolean isLetter(char ch)
Returns:
true
Example:
public class Test { public static void main(String args[]) { System.out.println(Character.isLetter('c')); System.out.println(Character.isLetter('5')); }
(2)
isDigit()
Determines whether the specified char value is a digit.
Syntax:
boolean isDigit(char ch)
Returns:
true
Example:
public class Test { public static void main(String args[]) { System.out.println(Character.isDigit('c')); System.out.println(Character.isLetter('5')); }
(3)
isWhitespace()
Determines whether the specified char value is white space.
Example:
public class Test{ public static void main(String args[]){ System.out.println(Character.isWhitespace('c'));
(4)
isUpperCase()
Determines whether the specified char value is uppercase.
Example:
public class Test{ public static void main(String args[]){ System.out.println( Character.isUpperCase('c')); System.out.println( Character.isUpperCase('C')); System.out.println( Character.isUpperCase('\n')); System.out.println( Character.isUpperCase('\t')); }
(5) isLowerCase()
Determines whether the specified char value is lowercase.
Syntax: boolean isLowerCase(char ch)
Returns:
true
Example:
public class Test{ public static void main(String args[]){ System.out.println(Character.isLowerCase('c')); System.out.println(Character.isLowerCase('C')); System.out.println(Character.isLowerCase('\n')); System.out.println(Character.isLowerCase('\t')); } }
(6)
the uppercase equivalent of the character, if any; otherwise, the character itself.
Example:
public class Test{ public static void main(String args[]){ System.out.println(Character.toUpperCase('c')); System.out.println(Character.toUpperCase('C')); }
(7)
toLowerCase()
Returns the lowercase form of the specified char value.
Syntax:
char toLowerCase(char ch)
Returns:
the lowercase equivalent of the character, if any; otherwise, the character itself.
Example:
public class Test{ public static void main(String args[]){ System.out.println(Character.toLowerCase('c')); System.out.println(Character.toLowerCase('C')); } }
(8)
toString()
Returns a String object representing the specified character value that is, a one-character string.
Syntax:
String toString(char ch)
Returns:
public static void main(String args[]){ String str; Char ch=A; str=Character.toString(ch); System.out.println(str); } }