Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Character Data Types

  • • The character data type is stored characters such as b,q,k,t,*, etc.
  • • This data type is represented by the key ward char.
  • • Char in Java is not the same as the char in c or c++ that means there is a difference.
  • • The difference is in C/C++ char is an integer type i.e. 8 bits(1byte)
  • • But java this is different. Java uses Unicode to represent a character.
  • • Unicode defines a fully international character set that represents all character found in all human language.
  • • It is a unification dozen character sets such as Latin, Greek, Arabic and many more.
  • • For this purpose, java character requires 2 bytes (16bits).
  • • The range of character is 0 to 65, 536. This means a total of 65536 distinct characters can be recognized by Java.
  • • In the Unicode system, the lowest value is \u0000 and the highest value is \uFFFF.
  • • Let us see a program to understand the char variables.

class Test
{
	public static void main (String args[ ])
	{
		char c1, c2;
		c1=90;
		c2 =?A?;
		System.out.println (c1+c2);
	}
}

Output

155

Let's see another program on the character data type.

class CharacterDemo
{
	public static void main (String args[ ])
	{
		char c1;
		c1 =?A?;
		c1++;
		System.out.println (?c1 is ?+c1);
	}
}

Output

B

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext