1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* Listing1107.java */
import java.util.*;
public class Listing1107
{
public static void main(String[] args)
{
//Boolesche Werte
System.out.format("%b %b %2$b %1$b%n", true, false);
//Ganzzahlen
System.out.format("[%d]%n", -2517);
System.out.format("[%7d]%n", -2517);
System.out.format("[%-7d]%n", -2517);
System.out.format("[%(7d]%n", -2517);
System.out.format("[%07d]%n", -2517);
System.out.format("[%,7d]%n", -2517);
System.out.format("%1$d %<o %<x %<X%n", 127);
//Flie�kommazahlen
System.out.format("%f%n", 0.000314);
System.out.format("%1$6.2f %1$6.2e %1$6.2E %1$6.2G%n", 3.141592);
System.out.format("%,8.2f%n", 31415.92);
System.out.format(Locale.ENGLISH, "%,8.2f%n", 31415.92);
//Zeichen und Strings
System.out.format("%c%c%c\n", 97, 64, 98);
System.out.format("%s nein\n", "ja");
//Datum/Uhrzeit
Calendar now = Calendar.getInstance();
System.out.format(
"%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS%n",
now
);
System.out.format("%tF%n", now);
System.out.format("%tc%n", now);
}
}
|