Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Taming Tiger, Part 1

An introduction to Java 1.5

  • Print
  • Feedback

Page 4 of 6

// Demonstrating printf versatility
System.out.printf("%02d + %02d = %02d\n", x, y, sum);


This line of code ensures that each number prints as two digits and, if the number is a single digit, then a zero (0) precedes it. So the output on the console now looks as follows: 05 + 06 = 11.

Enumerations

Consider the following class:

public Class Color
{
   public static int Red = 1;
   public static int White = 2;
   public static int Blue = 3;
}


You could use the class as shown in the following code fragment:

  • Print
  • Feedback

Resources