Home Segments Top Top Previous Next

64: Mainline

You can initialize a variable in the same statement in which the variable is declared:

public class Demonstrate { 
 public static void main (String argv[]) { 
  int script = 6; 
  int acting = 9; 
  int direction = 8; 
  ... 
 } 
} 

You can combine several declarations, with initializations, into one concise statement, as in the following example:

public class Demonstrate { 
 public static void main (String argv[]) { 
  int script = 6, acting = 9, direction = 8; 
  ... 
 } 
} 

Again, note the obligatory commas.