store string elements in character array in java
import java.util.*;
public class GFG {
public static void main(String args[])
{
String str = "GeeksForGeeks";
// Creating array and Storing the array
// returned by toCharArray()
char[] ch = str.toCharArray();
// Printing array
for (char c : ch) {
System.out.println(c);
}
}
}
// Java program to Convert a String
// to a Character array using Naive Approach
import java.util.*;
public class GFG {
public static void main(String args[])
{
String str = "GeeksForGeeks";
// Creating array of string length
char[] ch = new char[str.length()];
// Copy character by character into array
for (int i = 0; i < str.length(); i++) {
ch[i] = str.charAt(i);
}
// Printing content of array
for (char c : ch) {
System.out.println(c);
}
}
}
Also in Java:
- how to set a windows background image tkinter
- finding min and max from given number in java
- non primitive data types in java
- hashmap get value by key java
- action on long press of edit edittext
- multiple string java
- how to play an audio in java
- protect java
- java merge sort
- remove last character from string java
- how to remove all whitespace from string java
- how to initiate a queue in java
- java get annotation value
- how to break two loop in java
- java read string input
- connect 2 package in android
- adding an element to the end of a linked list java
- java iterator example
- how to ask user for his location in android
- spigot kill entity
- java how to make a gui
- write file from a specific location in java
- get value textfield java
- java scanner