1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* 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 would be Value of char variable ch1 is :a Value of char variable ch2 is :A */ |
Add Comment