I'm new to Java, obviously, and am working on homework where I'm given an array and then have to mentally manipulate it with various for loops several times. I've completed my work however I, being new to and excited about computer science, figured I could write a basic program to check my work.
This is the code I've written and my compiler keeps yelling at me that it "cannot find symbol - variable a" towards the bottom there. My ignorant thinking tells me that I created "a" when I named the array "a". Sadly I haven't been able to find an example code similar to this. Can you guys tell me what I'm doing wrong?
import java.util.Scanner;
public class ArrayTest
{
public static void main(String[] args)
{
int[] a = { 1, 2, 3, 4, 5, 4, 3, 2, 1, 0 };// the array I'm working on
}
{
for (int i = 1; i < 10; i++) { a[i] = a[i - 1]; } //the manipulation given
}
{
System.out.println(a[i]);
}
}
Thank you!