Java Character class

Introduction

Character is a wrapper around a char.

The constructor for Character is

Character(char ch)                                                                                   

Here, ch is the character that will be wrapped by the Character object.

To get the char value from a Character object, call charValue():

char charValue() 

It returns the encapsulated character.

public class Main {

  public static void main(String[] args) throws Exception{
    char c = 'C';
    String str = Character.toString(c);
    System.out.println(str);//from   w  w  w .  j  a  v a  2  s  . c om

    c = 'D';
    Character instance = new Character(c);
    str = instance.toString();
    
    System.out.println(str);    
  }
}



PreviousNext

Related