Algorithms and Data Structures
Quick Links
What's New 
Home 
Contacts 
Course Book 
Java Book 
JDK & JDSL 
Slides 
Notes 
Demos 
Exercises 
Marks
 
Java for the Course 
We need to go beyond what we were taught about Java in first year. In particular, we need to know (more) about recursion, exception handling, enumeration, casting, etc. Therefore, the following notes attempt to go some way to achieving that. The approach I am taking is to work through one or two cases, for example a course of students and a linked list. I will implement the data structure and then put it to use in a number of applications. This will be my vehicle. 
  • Things, Students, and Courses ... a kick start into Java, with a simple class (the Thing, that you might use as a template), modified to becom a Student, and then contained with in a Course. This little example revists polymorphism, iteration, arrays, etc.
  • Reading from a file using MyIo. Have a look at the Test program to see how to use it.
  • Using a vector and enumeration to produce the Course rather than use an array.
  • Linked Lists. I produce an abstract data type for a (linked) list of integers. We encounter recursion.
  • Generic Lists. The list above is kind of restrictive, only integers. Now I produce a list of objects. I hit some problems, such as how do I test for equality or order between arbitrary objects? I also introduce exceptions, and owned variables (counting the number of constructions).
  • To Do Lists. Okay, so I have a generic list (of objects). Put it to use. I define a ToDo List.
  • Lists of Integers. Again? Let's go back and do a retro-fit, using the generic list to implement a list of integers.
  • Composition or Inheritance? When do we use composition, when do we use inheritance. I try to produce an integer list via inheritance, and hit a limit. I use composition, and learn some things.
  • Enumeration. We want to be able to do something with all elements in a collection. We do this by enumeration. This is shown with a number of our lists and with a stack.
  • Exceptions, catch and throw. How do we handle bad situations?

Copyright © Patrick Prosser 1999.