public class ConvertCharToString { public static void main(String[] args) {
String name = "Sardar";
//get the first character from the string
char firstChar = name[0];
// convert the character to string again
String temp = Character.toString(firstChar);
// check if the char is converted correctly
if ( "S".equals(temp) )
{
System.out.println("String Matched");
}
}
}
No comments:
Post a Comment