How To Convert Char To String In Java?

This post highlights a simple example to demonstrates how to convert a char datatype to a string object. Lets look at the example program.


public class CharToStringExample {
	public static void main(String args[]) {
		String str = "javabeat";

		// convert a String object to char
		char charVal = str.charAt(3);

		// 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");


Value Matching

Leave a Reply

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

Pin It on Pinterest

Share This

Share this post with your friends!