CodesJava

Easy learning with example program codes

Char Data Type in 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 CodesJava
 */
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

 

Please follow and like us:
error
Posted in Java   








Copyright © 2019 CodesJava DMCA.com Protection Status