public class StaticCharMethods
1: // Fig. 29.15: StaticCharMethods.java
2: // Static Character testing methods and case conversion methods.
3: import java.util.Scanner;
4:
5: public class StaticCharMethods
6: {
7: public static void main( String args[] )
8: {
9: Scanner scanner = new Scanner( System.in ); // create scanner
10: System.out.println( "Enter a character and press Enter" );
11: String input = scanner.next();
12: char c = input.charAt( 0 ); // get input character
13:
14: // display character info
15: System.out.printf( "is defined: %b\n", Character.isDefined( c ) );
16: System.out.printf( "is digit: %b\n", Character.isDigit( c ) );
17: System.out.printf( "is first character in a Java identifier: %b\n",
18: Character.isJavaIdentifierStart( c ) );
19: System.out.printf( "is part of a Java identifier: %b\n",
20: Character.isJavaIdentifierPart( c ) );
21: System.out.printf( "is letter: %b\n", Character.isLetter( c ) );
22: System.out.printf(
23: "is letter or digit: %b\n", Character.isLetterOrDigit( c ) );
24: System.out.printf(
25: "is lower case: %b\n", Character.isLowerCase( c ) );
26: System.out.printf(
27: "is upper case: %b\n", Character.isUpperCase( c ) );
28: System.out.printf(
29: "to upper case: %s\n", Character.toUpperCase( c ) );
30: System.out.printf(
31: "to lower case: %s\n", Character.toLowerCase( c ) );
32: } // end main
33: } // end class StaticCharMethods
34:
35: /**************************************************************************
36: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
37: * Pearson Education, Inc. All Rights Reserved. *
38: * *
39: * DISCLAIMER: The authors and publisher of this book have used their *
40: * best efforts in preparing the book. These efforts include the *
41: * development, research, and testing of the theories and programs *
42: * to determine their effectiveness. The authors and publisher make *
43: * no warranty of any kind, expressed or implied, with regard to these *
44: * programs or to the documentation contained in these books. The authors *
45: * and publisher shall not be liable in any event for incidental or *
46: * consequential damages in connection with, or arising out of, the *
47: * furnishing, performance, or use of these programs. *
48: *************************************************************************/