Howdy. 

I am to write copyOf and toString. 

If I can do it, I can also write a program. 

Let me show you how I would do it. 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Downloads
> int[] a = {3, 2, 5};
> String result; 
> result = ""; 
> int i = 0;
> result = result + ", " + a[i++];
> i
1
> result
", 3"
> result = result + ", " + a[i++];
> result = result + ", " + a[i++];
> i
3
> result
", 3, 2, 5"
> result = "[" + result.substring(2) + "]";
> result
"[3, 2, 5]"
>

That's how your method should proceed too (modulo some details). 

public class LabSix {
  public static String toString(int[] a) {
    // return " to be determined ";  
    return java.util.Arrays.toString( a ); 
  }
  public static int[] copyOf(int[] original, int newLength) {
    return new int[newLength];     
  }
}

Combine this with the main program:

public class LectureSix {
  public static void main(String[] args) {
    java.util.Scanner speckles = new java.util.Scanner(System.in); 
    int[] numbers = new int[0]; 
    while (true) {
      System.out.print("number> "); 
      String input = speckles.nextLine();
      if (input.equals("bye"))
        break; 
      int number = Integer.parseInt( input ); 
      numbers = LabSix.copyOf( numbers, numbers.length + 1 ); 
      numbers[numbers.length - 1] = number;
      System.out.println( LabSix.toString( numbers ) ); 
    }
    // this is the first statement after the loop
    java.util.Arrays.sort( numbers ); 
    System.out.println( LabSix.toString( numbers ) ); 
    System.out.println("Thanks for using this program."); 
  }
}

Now you have a framework, a setup for what you need to do. 

I finish by telling you what the steps of the second method should be: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> int[] a = {4, 5, 6};
> a
{ 4, 5, 6 }
> int[] b = new int[a.length + 1]; 
> b
{ 0, 0, 0, 0 }
> for (int i = 0; i < a.length; i++) b[i] = a[i]; 
> b
{ 4, 5, 6, 0 }
> a
{ 4, 5, 6 }
> a = b
{ 4, 5, 6, 0 }
> a
{ 4, 5, 6, 0 }


Notice how my extremely simple copyOf (the stub) is almost working. 


public class LabSix {
  // ... 
  public static int[] copyOf(int[] original, int newLength) {
    return new int[newLength];     
  }
}

To finish it you'd have to follow the steps above, with b, then return b. 

--