Hello im having problems with my code.
i wanted to make a program that would let me enter anything
and then place each one of them inside the array.
import java.util.*;
class charAt
{
public static void main(String[]args)
{
Scanner input=new Scanner(System.in);
String[]sample=new String[52];
String enter;
int x;
System.out.println("Enter something");
enter=input.next();
for(x=0;x<sample.length();x++)
{
sample[x]=enter.charAt(x);
}
}
}
example i would enter "abcd1234"
i wanted it to placed inside the array
sample[0]=a
sample[1]=b
sample[2]=c
sample[4]=d
sample[5]=1
sample[6]=2
sample[7]=3
sample[8]=4
but my code seems to have an error... i need help
i only can use a String array.