Complete the code below that aims to convert the String "input"
to a static array of char named "array". You are NOT allowed to use
String's toCharArray method!
java
String input = "Have you voted yet?"; char array[] =
public class Main {
public static void main(String[] args)
{
String input= "Have you voted
yet?";
//declare array
char array[] =new char[input.length()];
//loop through all of it
for(int i=0;i<input.length();i++)
{
//place the item at i position to array position
array[i]=input.charAt(i);
}
System.out.println(array);
}
}
comment if any doubts
Get Answers For Free
Most questions answered within 1 hours.