Java.lang.Character.charValue() Method
Advertisements
Description
The java.lang.Character.charValue() returns the value of this Character object.
Declaration
Following is the declaration for java.lang.Character.charValue() method
public char charValue()
Parameters
NA
Return Value
This method returns the primitive char value represented by this object.
Exception
NA
Example
The following example shows the usage of lang.Character.charValue() method.
package com.tutorialspoint;
import java.lang.*;
public class CharacterDemo {
public static void main(String[] args) {
// create a Character object c
Character c;
// assign value to c
c = new Character('a');
// create a char primitive ch
char ch;
// assign primitive value of c to ch
ch = c.charValue();
String str = "Primitive char value is " + ch;
// print ch value
System.out.println( str );
}
}
Let us compile and run the above program, this will produce the following result:
Primitive char value is a