In Java there are eight primitive types:

  int         long  short  byte 

  double      float 

  char

  boolean 

What is a type? 

A type is a set of values with operations defined on it. 

  boolean a, b; 
  a = ... ;
  b = ... ;
  System.out.println( !(a && b) == (!a || !b) ); // always prints true 

These types are truly different from the rest of Java. 

Java a language of objects. 

Other than primitive types we have reference types (classes, user-defined types). 

Wrapper classes are meant to make everything in Java act and look like (be) an object. 

class Counter {
  int balance;
  void increment() {
    balance += 1;  
  }
  int getValue() {
    return balance; 
  }
}

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> int[] a
> a = new int[6]
{ 0, 0, 0, 0, 0, 0 }
> a[0] = 3
3
> a[1] = -2
-2
> a[5] = 9
9
> a
{ 3, -2, 0, 0, 0, 9 }
> Integer[] b
> b = new Integer[8]
{ null, null, null, null, null, null, null, null }
> b[7] = 3
3
> b
{ null, null, null, null, null, null, null, 3 }
> b[6] = 3
3
> b[6] - b[7] 
0
> b[6] == b[7]
true
> b[5] = new Integer(3)
3
> b
{ null, null, null, null, null, 3, 3, 3 }
> b[5] == b[6]
false
> b[5].equals(b[6])
true


Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> ArrayList<Integer> a
Static Error: Undefined class 'ArrayList'
> import java.util.ArrayList; // auto-import
ArrayList<Integer> a
> a
null
> a = new ArrayList<Integer>()
[]
> a.add(4)
true
> a
[4]
> a.add(3)
true
> a.add(-2)
true
> a.add(12)
true
> a
[4, 3, -2, 12]
> a.remove(1)
3
> a
[4, -2, 12]
> ArrayList<int> b
Static Error: Type has incompatible bounds
> int[] c = {1, 3, 1, 2, 5}
> c
{ 1, 3, 1, 2, 5 }
> int[] d
> d = new int[] {1, 3, 2, 4, 1, -6, 9}
{ 1, 3, 2, 4, 1, -6, 9 }
>

The same thing using ArrayList<...> has very ugly syntax. 

import java.util.Arrays; 

class Homework {
  public static void main(String[] args) {
    int[] a;
    a = new int[6];
    a[1] = 4;
    a[3] = -1;
    System.out.println( a ); // [I@fc752c3
    System.out.println( Arrays.toString( a ) ); // [0, 4, 0, -1, 0, 0]
    a[a.length-1] = 13;
    System.out.println( Arrays.toString( a ) ); // [0, 4, 0, -1, 0, 13] 
    a = Arrays.copyOf(a, a.length + 1);
    System.out.println( Arrays.toString( a ) ); // [0, 4, 0, -1, 0, 13, 0] 
    a[a.length - 1] = 9;
    System.out.println( Arrays.toString( a ) ); // [0, 4, 0, -1, 0, 13, 9] 
    
  }
}

So you need to define these two methods for the homework. 

--