Share on Google+Share on Google+

Java char data type

Advertisement
The char is a primitive data type. It is 16 bit type and used to represent Unicode characters. The range of char is 0 to 65,536. Below given a simple example of char data type.

Code:

public class JavaChar {
  public static void main(String[] args) {
    char chr1 = 'e';
    char chr2 = 69;
    System.out.println("Value of char variable chr1 is :" + chr1);
    System.out.println("Value of char variable chr2 is :" + chr2);
  }
}

Output:

Download this code

Java Escape Sequences
This tutorial demonstrate the java escape sequence with example.
 
Use char variable as integer
This tutorial demonstrate how to use the char variable as an integer.
 
Check character in upper case or not.
This example check for the character in uppercase or not.
 
Check for character in lower case or not.
This example check for the character in lowercase or not.
 
Check for character is digit or not.
This example check for the character is digit or not. It returns Boolean value.
 
Check for character is letter or not.
This example check for the character is letter or not. It returns Boolean value.
 
Count letters in a string.
This example counts letter present in string.
 
Check for character is letter or digit.
This example checks for character variable value is letter or digit.
 
Check for character having white space or not
This example help you find whether the char variable's value is having white space or not
 
Convert ASCII to string
This example help you to convert ASCII to string in java.
 
Convert integer to ASCII
This example demonstrate how to convert integer to ASCII in java.
 
Copy char array into string
This example will help you to know how to copy array of char data type into a string.
 
Convert string into character array
This example helps you know how to convert string into character array.
 
Compare two char array in java
This tutorial helps you to know how to compare two char array in java.
 

Advertisements

Posted on: June 25, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.