import java.util.ArrayList; 
import java.util.Scanner; 
import java.util.Collections; 

public class Whatever {
  public static void main(String[] args) {
    int[] a; // declare 
    a = new int[3]; // allocate
    a[1] = -4; // initialize 
    ArrayList<String> b; // declaration 
    b = new ArrayList<String>(); // allocation 
    System.out.println( b ); // using it 
    System.out.println( b.size() ); 
    b.add("Andrew"); 
    b.add("Kevin"); 
    System.out.println( b );  
    System.out.println( b.size() );    
    
    ArrayList<String> c; 
    c = new ArrayList<String>(); 
    System.out.println( c );
    Scanner something = new Scanner(System.in); 
    System.out.print("type: "); 
    String line = something.nextLine(); 

    while (! line.equals("bye")) {
      c.add(line); 
      System.out.println( c );
      System.out.print("type: "); 
      line = something.nextLine();            
    }
    
    System.out.println( c );
    Collections.sort(c); 
    System.out.println( c );    
    
  }
}

This program runs as follows: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run Whatever
[]
0
[Andrew, Kevin]
2
[]
type:  [DrJava Input Box]
[Xinyu]
type:  [DrJava Input Box]
[Xinyu, Jiahao]
type:  [DrJava Input Box]
[Xinyu, Jiahao, Xing]
type:  [DrJava Input Box]
[Xinyu, Jiahao, Xing, Levi]
type:  [DrJava Input Box]
[Xinyu, Jiahao, Xing, Levi, Jiebo]
type:  [DrJava Input Box]
[Xinyu, Jiahao, Xing, Levi, Jiebo, Yinan]
type:  [DrJava Input Box]
[Xinyu, Jiahao, Xing, Levi, Jiebo, Yinan]
[Jiahao, Jiebo, Levi, Xing, Xinyu, Yinan]



Here's another problem:

class Nothing { 
  public static void main(String[] args) { 
    
    int[][] a = { { 1, 2, 3, 4},
                  { 2, 3, 4}, 
                  { 3, 4},
                  { 4} 
                };
    
    {
      int sum = 0; 
      for (int i = 0; i < a.length; i++) 
        System.out.print(a[i].length); 
    }
    
    {
      int sum = 0; 
      for (int i = 0; i < a.length; i++) 
        for (int j = 0; j < a[i].length; j++) 
        sum += a[i][j];
      System.out.println(sum);
    }
  }
}

So the pairs of curly brackets define anonymous, distinct scopes for the variables declared inside (sum). 

--