I'm currently learning Java and refreshing what I've previously learn t, I'm making a quick test array in this class but want to add an index onto the array so the output has a number for the peanuts left. so ideally the array would start at 5 and count down.
I remember it being a few lines of code, but what those are.... has escaped me.
public class Testing123 {
public static void main(String[] args){
String p = " Peanuts left in the jar.";
int[] anArray = new int[5];
for(int i=0; i<anArray.length; ++i){
int index = 0;
System.out.println(anArray[i] + p);
++index;
}
}
}
indexvariable? It is not even being used.