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.


//  w  w  w.j  a  v a 2 s .  co  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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable