Program for example 001 (Java).