Overview



Collection Classes



Java Arrays Review



Cloning Arrays and Typecasts



Array properties



Bags, Sets, Sequences



A Bag of Integers



Specification



Specification for add



Specification for remove



Specification for clone



Implementation of clone

public class IntArrayBag
   implements Cloneable
{ 
  private int [] data;
  ...
public Object clone()
{
  IntArrayBag answer;
  try {
    answer = (IntArrayBag) super.clone();
  } catch (CloneNotSupportedException e)
  {
    ...
  }
  answer.data = (int []) data.clone ();
  return answer;
}