Java autoboxing unboxing Character Values

Introduction

Java Character is wrapper class for char.

Autoboxing/unboxing applies to Character object.

public class Main { 
  public static void main(String args[]) { 
    // ww w  .  j av a  2 s.c  o  m
    // Autobox/unbox a char. 
    Character ch = 'x'; // box a char 
    char ch2 = ch; // unbox a char 
 
    System.out.println("ch2 is " + ch2); 
 
  } 
}



PreviousNext

Related