|
Do you need help with your Java programming?
Click here for instant help with your Java code. |
Using the Character class
This code example shows a few of the methods of the Character class. First a variable c is declared which is a variable of type "char" and it is assigned the value "a". The methods isLowerCase, isUpperCase and isLetter which all returns a boolean value are used to check whether the variable is uppercase, lowercase or if it's a letter. Finally the results are displayed using System.out.println statements. |
package com.javadb.examples; public class CharacterDemo { public static void main(String args[]) { char c = 'a'; boolean lowerCase = Character.isLowerCase(c); boolean upperCase = Character.isUpperCase(c); boolean letterOrDigit = Character.isLetter(c); System.out.println("Is c lowercase? " + lowerCase); System.out.println("Is c uppercase? " + upperCase); System.out.println("Is c a letter? " + letterOrDigit); } } |
| Do you know your Java? | |
| Take a Ten-Question-Java-Quiz! | |
Search for code examples on this site
