This post highlights a simple example to demonstrates how to convert a char datatype to a string object. Lets look at the example program.
package javabeat.net.core; public class CharToStringExample { public static void main(String args[]) { String str = "javabeat"; // convert a String object to char char charVal = str.charAt(3); System.out.println(charVal); // convert char back to String object String convertStr = Character.toString(charVal); //Check if it matches with the char if ("a".equals(convertStr)) { System.out.println("Value Matching"); } } }
Output
a Value Matching