Friday, 1 August 2014

convert character to string in java

There are many ways to convert a character to a string.

Example
public class CharToString {
   public static void main(String args[]){
       char ch = 'a';
       
       String str1 = String.valueOf(ch);
       String str2 = Character.toString(ch);
       String str3 = "" + ch;
       String str4 = new String(new char[]{ch});
   } 
}



                                                             Home

No comments:

Post a Comment