I have an array of type char and a string that I will be introducing from the keyboard. Can anyone tell me how can I introduce each character of the string in the char array?
2 Answers
string.toCharArray() will convert a String to a char array.
Alternatively, iterate over the string's characters and store them into your array:
char[] myArray = ...
int index = ...
for(int i = 0 ; i < string.length() ; i++) {
char c = string.charAt(i);
myArray[index] = c;
index++;
}
This question does not show any research effort; it is unclear or not useful.