Convert char To String in Java

Convert char To String in Java Example describes about How To Convert char To String in Java.

Character class helps to wrap the primitive type value of char in an object. It also provides several utility functions for determining whether a character is lowercase, uppercase, digit, etc.

In addition, Character class provides several useful methods for dealing with char. When you need to Convert char To String in Java, we can use Character.toString(char c) method of Character class, It will convert the char to String.

If you need an Character object in lieu of primitive char, you can use Character.valueOf(char c). It will convert the char primitive to Character Object

Convert char To String In Java

public class ConvertCharToString {

 
public static void main(String[] args) {
  
   
char c = 'c';

   
// convert char to String type
   
System.out.println(Character.toString(c));
  
   
// convert char primitive to Character type
   
System.out.println(Character.valueOf(c));
  
 
}
}
Output
c

c








Your email address will not be published. Required fields are marked *