character in java

Java Programming Language / Character Class in java

25802

Program:

 /*
        Java char Example
        This Java Example shows how to declare and use Java primitive char variable
        inside a java class.
*/
 
public class JavaCharExample {
 
        public static void main(String[] args) {
               
                /*
                 * char is 16 bit type and used to represent Unicode characters.
                 * Range of char is 0 to 65,536.
                 *
                 * Declare char varibale as below
                 *
                 * char <variable name> = <default value>;
                 *
                 * here assigning default value is optional.
                 */
 
                char ch1 = 'a';
                char ch2 = 65; /* ASCII code of 'A'*/
               
                System.out.println("Value of char variable ch1 is :" + ch1);   
                System.out.println("Value of char variable ch2 is :" + ch2);             
        }
}
 

Output:

Value of char variable ch1 is :a
Value of char variable ch2 is :A
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.