If you're going to use an Iterator, that's fine. If you're going to use a for loop to step through the List, that's also fine.
The problem is that you're trying to combine the two. Your while loop executes until the Iterator has no more elements, but you're never advancing the Iterator to the next element.
Also, your index within the for loop is set to either 0 or 1. You probably want to use i rather than 1. [ November 09, 2006: Message edited by: Mark Van Tuyl ]
Create a variable to hold the previous term and initialize it to zero. Add the current and previous terms to obtain the result and save the current term in the 'previous' variable.
Once a number has been selected, set it to -1 (or some other invalid value). Before displaying a number, make sure it's valid. Otherwise, select another.
What you've got will indeed define a new type of Exception.
I would suggest, however, that you include the call to super() in both constructors. Otherwise, when creating an instance of the exception using the default constructor, no specific information about the exception will be available.
"Person extends Employee - Person is a Employee - not sure about this one is sounds like it makes sense but not sure though but I guess sicne not every person is a employee it would not work."
It works the other way around - every Employee is a Person.
"Ferrari extends Engine - Ferrari is a Engine - does not make sense but ferrair has a Engine so Ferrari would be a instance variable of Engine?"
Ferrari has an Engine, so Ferrari would implement the Engine interface.
"Container extends Jar - Container is a Jar - could make sense too since a Container could be a Jar."
But not all Containers are Jars. The reverse works: Jar is a Container so Jar extends Container.
"Beverage extends Martini - Beverage is a Martini -- this one to me could work too since martini could be classified as Beverage but then again not every beverage is a Martini."
Again, it's reversed - Martini is a Beverage, so Martini extends Beverage.
This looks kind of odd to me The if statement attempts to retrieve a StudentRecord object from the array. It then attempts to compare the name in the object to the name provided. If they're not equal, it creates a StudentRecord object at that position in the array.
Why not make sure the object exists before trying to call a method on it?