doing some thinking in java exercises