Workshop: Teaching Your Computer a Lesson

This hour's workshop provides evidence that you cannot punish your computer in the same way that Bart Simpson is punished at the beginning of each episode of The Simpsons. Pretend you're a teacher and the computer is a kid who contaminated your morning cup of coffee with Thorium 230.

Even if you're the most strident liberal, you realize that the computer must be taught a lesson—it's not acceptable behavior to give the teacher radiation poisoning. Your computer must be punished, and the punishment is to display the same sentence over and over again.

The Repeat program will use a loop statement to handle a System.out.println() statement again and again. Once the computer has been dealt this punishment for ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.