Here we will write to program in Java to convert Char Array to String Array
In this post we will write a program in Java to convert a char array to string array, we will explain this with the help of example.
In this post we will write a program in Java to convert a char array to string array, we will explain this with the help of example.
/* | |
Java Char Array To String Example | |
This Java char array to String example shows how to convert char array to | |
String in Java. | |
*/ | |
public class CharArrayToStringExample { | |
public static void main(String args[]){ | |
//char array | |
char[] charArray = new char[]{'J','a','v','a'}; | |
/* | |
* To convert char array to String in Java, use | |
* String(Char[] ch) constructor of Java String class. | |
*/ | |
String str = new String(charArray); | |
System.out.println("Char array converted to String: " + str); | |
} | |
} | |
/* | |
Output of above given char array to String example would be | |
Char array converted to String: Java | |
*/ |
No comments:
Post a Comment