• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Java Character Class

by admin

In this post, we discuss the character class in java.

Example:

char ch = 'x';

// Unicode for uppercase Greek omega character
char uniChar = '\u039A'; 

// an array of chars
char[] charArray ={ 'x', 'y', 'z' };

Java provides wrapper class Character for primitive data type char. You can create a Character object with the Character constructor:

Character ch = new Character('x');

Escape Sequences

A character preceded by a backslash (\) is an escape sequence and has a special meaning to the compiler. The newline character (\n) has been used frequently in this tutorial in System.out.println() statements to advance to the next line after the string is printed.

Escape Sequence Description
\t Use to Inserts a tab in the text at this point.
\n Use to Inserts a newline in the text at this point.
\f Use to Inserts a form feed in the text at this point.
\r Use to Inserts a carriage return in the text at this point.
\” Use to Inserts a double quote character in the text at this point.
\’ Use to Inserts a single quote character in the text at this point.
\\ Use to Inserts a backslash character in the text at this point.

Example
use the escape sequence, \”, on the interior quotes:

public class Test {

   public static void main(String args[]) {
      System.out.println("Hello \"World\" !");
   }
}

Output

Hello "World" !

Character Methods

Following is the list of the important instance methods that all the subclasses of the Character class implement −

Method Description
isLetter() This method Determines whether the specified char(ch) value is a letter..
isDigit() This method Determines whether the specified char(ch) value is a digit.
isWhitespace() This method Determines whether the specified char value is white space.
isUpperCase() This method Determines whether the specified char(ch) value is uppercase.
isLowerCase() This method Determines whether the specified char(ch) value is lowercase.
toString() Returns a String object representing the specified character value that is, a one-character string.

Following is the list of the important instance methods that all the subclasses of the Character class implement −

Filed Under: Java

Some more articles you might also be interested in …

  1. Java Basics: Lambda Built-in Functional Interfaces
  2. Java Basics: Abstract and Nested Classes
  3. Java Encapsulation
  4. kotlin Command Examples (Kotlin application launcher)
  5. Basics of Java Variables
  6. Java Classes and Objects
  7. Apache Ant – Tool for building and managing Java-based projects.
  8. Introduction to Exceptions in Java
  9. Introduction to Java Interfaces
  10. Java Date and Time

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright