I am in my first class of Java programming and one of the assignments we were given was to create a value string which displays in reverse order separated by commas. I know I am probably missing something very simple, but after hours of trying I just don't know where I am going wrong?
My code works, however I keep getting this error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at ip2_jolley.IP2_Jolley.main(IP2_Jolley.java:148)
Three, Two, One Java Result: 1
This is the code I am using:
String[] f = {"One", "Two", "Three"};
if (f.length > 0) System.out.print (f[2]);
for (int i = 1; i < f.length; i--){
System.out.print(", " + f[i]);
}