Here is my code, i am getting the following error message. How do i handle it?
package simp;
import java.io.*;
public class fCase {
public static void main(String [] args) throws IOException {
BufferedReader readObject = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your expressions here");
String userEntry = readObject.readLine();
String [] toki = userEntry.split(" ");
for (int i=0; i<=toki.length; i++) {
System.out.println(toki [i]);
//System.out.println(i + ": " + args[i]);
}
}
}
After inputing the following expression, this follows;
Enter your expressions here
what is your name?
what
is
your
name?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at simp.fCase.main(fCase.java:24)