Char Java

 
The char data type represents a single 16-bit Unicode character. It has a minimum value of ‘\u0000’ (or 0) and a maximum value of ‘\uffff’ (or 65,535 inclusive).

Program to declare and use Java primitive char variable.

/**
 * Program to declare and use Java primitive char variable.
 * @author W3spoint
 */
public class DataTypeCharExample {	
  public static void main(String args[]){ 
	//Declare char type variables.
	char ch1 = 'A';
        char ch2 = 66;
 
        //Print variables value.
        System.out.println("ch1 Value :" + ch1);
        System.out.println("ch2 Value :" + ch2);
  }
}

Output:

ch1 Value :A
ch2 Value :B

 

Content Protection by DMCA.com
Please Share