![]() |
![]() |
![]() |
![]() |
![]() |
|
Your variable-declaration statements do not need to lie before all other statements. Accordingly, most programmers prefer to declare each variable close to its first use, as in the following example:
public class Demonstrate {
public static void main (String argv[]) {
int result, script = 6;
result = script;
int acting = 9;
result = result + acting;
int direction = 8;
result = result + direction;
System.out.print("The rating of the movie is ");
System.out.println(result);
}
}