filmov
tv
How to convert a character array to string in Java

Показать описание
#char array to string
public class Char_to_String
{
public static void main(String[] args)
{
String str="";
char[] ch=new char[]{'h','i','j','a','v','a'};
//i have stored all characters in array
//because array is a collection of similar data types
str=new String(ch); //Create string object and pass ch
//then simply print str
}
}
public class Char_to_String
{
public static void main(String[] args)
{
String str="";
char[] ch=new char[]{'h','i','j','a','v','a'};
//i have stored all characters in array
//because array is a collection of similar data types
str=new String(ch); //Create string object and pass ch
//then simply print str
}
}