can anyone here help explain why my code is always getting an outOfBoundsExce ption error??? I want to be the one to do the necessary changes to the code, I just need some explanation. Here is my code.
Code:
import java.io.*;
public class Comp
{
public static void main(String args[]) throws IOException
{
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
String input;
System.out.print("Enter Input String: ");
input = buff.readLine();
char [] in = input.toCharArray();
for(int i=0;i<in.length;i++)
{
while(!(in[i]==' '))
{
System.out.print(in[i]);
i++;
}
System.out.print("\n");
}
}
}
Comment