\\java.lang.ArrayIndexOutOfBoundsException
import java.util.Scanner; public class pigLatin { public static void main(String[ ] args){ Scanner input = new Scanner(System.in); String text = input.nextLine(); StringBuilder s1 = new StringBuilder (text); char[ ] c = new char[s1.length()]; s1.append(' '); c[0]= s1.charAt(0); s1.deleteCharAt(0); for( int i = 0; i<s1.length(); i++ ) { if( s1.charAt(i) == ' ') { for(int j = 1; j<s1.length(); j++) { c[j] = s1.charAt(i+1); s1.deleteCharAt(i+1); s1.insert(i, c[i-1]); s1.insert(i, "ay"); } } } System.out.println(s1); } } The above code can run and get user input but it can't print output as expect because of the exception. I think it probably due to output's capacity is greater than the input 's length... I've scratch my mind for an hour then I still have no idea. Could someone help me out, please!!? @@