System.out.println()
System.out.println("Hello World");
System.out.println(pricePerGallon); System.out.println(isFinished); System.out.println(bigNumber); System.out.println(anotherBigNumber); System.out.println('\n');
System.out.print()
totalPrice = gallons * pricePerGallon + gallons * TAX_PER_GALLON; totalOz = numberOfCones * OZ_PER_CONE; System.out.print("The total oz of ice cream needed is "); System.out.print(totalOz); System.out.println();
System.out.printf( format, value1, value2, ...)
%X
System.out.printf("The total oz of ice cream needed is %d.%n", totalOz);
System.out.printf("We sold %d cones or %d oz.%n%n",numberOfCones, totalOz);
%,d
will print commas.
System.out.printf("A large number is %,d!%n", largeNumber);
%nd
will print an integer using at least n spaces.
System.out.printf("A large number is %30d!%n", largeNumber);
System.out.printf("A large number is %3d!%n", largeNumber);
System.out.printf("A large number is %-30d!%n", largeNumber);
%f
specifier
System.out.printf("The price per gallon is $%f.\n", pricePerGallon); System.out.printf("The price per gallon is $%10f.\n", pricePerGallon); System.out.printf("The price per gallon is $%.2f.\n\n", pricePerGallon); System.out.printf("The tax per gallon is $%f.\n",TAX_PER_GALLON); System.out.printf("The tax per gallon is $%.2f.\n",TAX_PER_GALLON);