Code from reading through Core Java Volume 1