String str = "example";
char[] ch = str.toCharArray();
public static void main(String[] args) {
String name = "chathumal";
char[] ch = name.toCharArray();
System.out.println(Arrays.toString(ch));
}
String myString = "Hello, world!";
char[] myCharArray = myString.toCharArray();
public class Demo {
public static void main(String []args) {
String str = "Tutorial";
System.out.println("String: "+str);
char[] ch = str.toCharArray();
System.out.println("Character Array...");
for (int i = 0; i < ch.length; i++) {
System.out.print(ch[i]+" ");
}
}
}
OUTPUT:
String: Tutorial
Character Array...
T u t o r i a l
var str = "HELLO";
var charArray = str.ToCharArray();
var strNew = new string(charArray);
let name = "King"
let arr = Array(name)
print(arr)
const string = 'word';
// Option 1
string.split('');
// Option 2
[...string];
// Option 3
Array.from(string);
// Option 4
Object.assign([], string);
// Result:
// ['w', 'o', 'r', 'd']
String s="abcd";
char[] a=s.toCharArray();
for(char c:a)
{ System.out.println(c); }