You need to know this!
public class myClass { /***** Global variables *****/ /* these variables can be accessed anywhere in this class */ //static variables (global) static int a = 100; static int b = (int) (0.75 * a); static final boolean YES = true; static final boolean NO = false; //instance variables (global) int c = 20; int d = c + 2; int speed = 3; static double squareMe(double d) { //d is a local variable created here int e = 7; //e is a local variable return d*d - e; //d is 5, the value that is passed in to squareMe } //local variables d and e are destroyed public static void main(String[] args) { System.out.print( "Global variable 'd' is " + d ); //d is 22 This is the global variable d System.out.print( squareMe(5) ); int sum = 0; //sum is created. It is a local variable for (int i = 0; i < 10; i++) { //i is created. It is a local variable sum += i; //you can use i here } //i is destroyed and cannot be used anymore System.out.print( sum ); } //end of main //all local variables created inside this { }, ie. args, sum, are destroyed } //private global variables cannot be accessed outside of this class