Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> import java.util.ArrayList;
> ArrayList<ArrayList<Integer>> matrix;
> matrix = new ArrayList
Incomplete expression
> matrix = new ArrayList<ArrayList<Integer>>();
> matrix
[]
> ArrayList<Integer> row = new ArrayList<Integer>();
> row
[]
> row.add(0)
true
> row.add(0)
true
> row.add(0)
true
> row
[0, 0, 0]
> matrix
[]
> matrix.add(row)
true
> matrix.add(row)
true
> matrix.add(row)\
Lexical error at line 1, column 17.  Encountered: <EOF> after : ""
> matrix.add(row)
true
> matrix
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
> row.set(1, 2)
0
> row
[0, 2, 0]
> matrix
[[0, 2, 0], [0, 2, 0], [0, 2, 0]]
> matrix = new ArrayList<ArrayList<Integer>>();
> matrix
[]
> matrix.add(new ArrayList<Integer>())
true
> matrix.add(new ArrayList<Integer>())
true
> matrix.add(new ArrayList<Integer>())
true
> matrix
[[], [], []]
> matrix.get(1).add(0)
true
> matrix.get(1).add(0)
true
> matrix.get(1).add(0)
true
> matrix
[[], [0, 0, 0], []]
> matrix.get(0).add(0)
true
> matrix
[[0], [0, 0, 0], []]
> matrix.get(2).add(0)
true
> matrix.get(2).add(0)
true
> matrix
[[0], [0, 0, 0], [0, 0]]
> matrix.get(0).add(0)
true
> matrix.get(0).add(0)
true
> matrix.get(2).add(0)
true
> matrix
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
> matrix.get(2).set(1, 1)
0
> matrix.get(0).set(2, 2)\
Lexical error at line 1, column 25.  Encountered: <EOF> after : ""
> matrix.get(0).set(2, 2)
0
> matrix
[[0, 0, 2], [0, 0, 0], [0, 1, 0]]
> matrix.get(1).set(0, 3)
0
> matrix.get(0).set(0, 4)
0
> matrix.get(1).set(1, 5)
0
> matrix.get(2).set(2, 6)
0
> matrix.get(1).set(2, 7)
0
> matrix
[[4, 0, 2], [3, 5, 7], [0, 1, 6]]
> matrix.get(2).set(0, 8)
0
> matrix
[[4, 0, 2], [3, 5, 7], [8, 1, 6]]
> matrix.get(0).set(1, 9)
0
> matrix\
Lexical error at line 1, column 8.  Encountered: <EOF> after : ""
> matrix

[[4, 9, 2], [3, 5, 7], [8, 1, 6]]


This was in response to how we avoid mistakes with array lists. 

You need to make sure you clone your object. 

Arrays and ArrayLists have one common property: the elements inside have the same type. 

int[] a; 
a = new int[20]; 

double[] b;
b = new double[6];

b[0] = 3.141592; 
b[1] = 2;

So now I want to answer these questions:

(a) can you model Point Line Circle Triangle Rectangle

(b) If I have the following code:

    Circle c = new Circle(); 
    Triangle t = new Triangle(); 
    Rectangle r = new Rectangle(); 

    ...[] a = new ...[3]; 
    a[0] = c;
    a[1] = t;
    a[2] = r;

Can you find a type to replace the ...?

The Class Extension Mechanism 

public class Horse {
  public Horse() {
    
  }
  public void talk() {
    System.out.println("Howdy I am " + this);  
  }
}

public class Unicorn extends Horse {
   
}

Simone is absent

So is Logan 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Horse a = new Horse()
> a
Horse@285d9925
> a.talk()
Howdy I am Horse@285d9925
> a
Horse@285d9925
> Unicorn b = new Unicorn()
> b.talk()
Howdy I am Unicorn@6bcf16c0
> b
Unicorn@6bcf16c0
> Horse c = new Unicorn()
> c.talk()
Howdy I am Unicorn@4ef9966a
> c.talk()

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Horse a
> a = new Unicorn()
Unicorn@4cb3a32e
> a
Unicorn@4cb3a32e
> a.talk()
Howdy I am Unicorn@4cb3a32e
> a.sing()
Static Error: No method in Horse has name 'sing'
> ((Unicorn)a).sing()
La la