(String[] args)
| 5 | |
| 6 | public class SimpleFormat { |
| 7 | public static void main(String[] args) { |
| 8 | int x = 5; |
| 9 | double y = 5.332542; |
| 10 | // The old way: |
| 11 | System.out.println("Row 1: [" + x + " " + y + "]"); |
| 12 | // The new way: |
| 13 | System.out.format("Row 1: [%d %f]%n", x, y); |
| 14 | // or |
| 15 | System.out.printf("Row 1: [%d %f]%n", x, y); |
| 16 | } |
| 17 | } |
| 18 | /* Output: |
| 19 | Row 1: [5 5.332542] |