Here is a problem that you can do if you want to get some practice for the final...

Write a Cat class. Its constructor should take a String as its input and store it as the name of the Cat.

In your public static void main(String[] args) method:

  1. Create an array of five Cats.
  2. Create five actual Cats named "Nora", "Heathcliff", "Cuddles", "Gremalkin", and "Charcoal", in that order.
  3. Print out the contents of the array. This means that your Cat class will need a toString() method. Having toString() return the name of the Cat probably makes sense. This also means that you will need to write a method printCats(Cat[] cats) in the same class as main(). (What happens if you make the input of printCats an array of Objects instead of an array of Cats? Why do you suppose that happens?)
  4. Use Arrays.sort() to sort the Cats. Think about what this means in terms of your Cat class. (You will need to implement the Comparable<Cat> interface.)
  5. Print out the contents of the array again to make sure that the sort worked.