| 7 | |
| 8 | public class Conversion { |
| 9 | public static void main(String[] args) { |
| 10 | Formatter f = new Formatter(System.out); |
| 11 | |
| 12 | char u = 'a'; |
| 13 | System.out.println("u = 'a'"); |
| 14 | f.format("s: %s%n", u); |
| 15 | // f.format("d: %d%n", u); |
| 16 | f.format("c: %c%n", u); |
| 17 | f.format("b: %b%n", u); |
| 18 | // f.format("f: %f%n", u); |
| 19 | // f.format("e: %e%n", u); |
| 20 | // f.format("x: %x%n", u); |
| 21 | f.format("h: %h%n", u); |
| 22 | |
| 23 | int v = 121; |
| 24 | System.out.println("v = 121"); |
| 25 | f.format("d: %d%n", v); |
| 26 | f.format("c: %c%n", v); |
| 27 | f.format("b: %b%n", v); |
| 28 | f.format("s: %s%n", v); |
| 29 | // f.format("f: %f%n", v); |
| 30 | // f.format("e: %e%n", v); |
| 31 | f.format("x: %x%n", v); |
| 32 | f.format("h: %h%n", v); |
| 33 | |
| 34 | BigInteger w = new BigInteger("50000000000000"); |
| 35 | System.out.println( |
| 36 | "w = new BigInteger(\"50000000000000\")"); |
| 37 | f.format("d: %d%n", w); |
| 38 | // f.format("c: %c%n", w); |
| 39 | f.format("b: %b%n", w); |
| 40 | f.format("s: %s%n", w); |
| 41 | // f.format("f: %f%n", w); |
| 42 | // f.format("e: %e%n", w); |
| 43 | f.format("x: %x%n", w); |
| 44 | f.format("h: %h%n", w); |
| 45 | |
| 46 | double x = 179.543; |
| 47 | System.out.println("x = 179.543"); |
| 48 | // f.format("d: %d%n", x); |
| 49 | // f.format("c: %c%n", x); |
| 50 | f.format("b: %b%n", x); |
| 51 | f.format("s: %s%n", x); |
| 52 | f.format("f: %f%n", x); |
| 53 | f.format("e: %e%n", x); |
| 54 | // f.format("x: %x%n", x); |
| 55 | f.format("h: %h%n", x); |
| 56 | |
| 57 | Conversion y = new Conversion(); |
| 58 | System.out.println("y = new Conversion()"); |
| 59 | // f.format("d: %d%n", y); |
| 60 | // f.format("c: %c%n", y); |
| 61 | f.format("b: %b%n", y); |
| 62 | f.format("s: %s%n", y); |
| 63 | // f.format("f: %f%n", y); |
| 64 | // f.format("e: %e%n", y); |
| 65 | // f.format("x: %x%n", y); |
| 66 | f.format("h: %h%n", y); |