Java Data Type Tutorial - Java Character.valueOf(char c)








Syntax

Character.valueOf(char c) has the following syntax.

public static Character valueOf(char c)

Example

In the following code shows how to use Character.valueOf(char c) method.

/*from   w ww. jav a2s .  c o  m*/
public class Main {

   public static void main(String[] args) {
      char ch1 = 'i', ch2 = 65;

      Character c1 = Character.valueOf(ch1);
      Character c2 = Character.valueOf(ch2);

      String str1 = "Character value of " + ch1 + " is " + c1;
      String str2 = "Character value of " + ch2 + " is " + c2;

      System.out.println( str1 );
      System.out.println( str2 );
   }
}

The code above generates the following result.