package com.javaex.reftype; public class StringFormatEx { public static void main(String[] args) { // %s, %d, %n String fruit = "Apple"; int total = 10; int eat = 3; System.out.println(10 + "ê°ì" + fruit + "ì¤ì" + eat + "ê°ë¥¼ 먹ìë¤."); // -> format System.out.printf("%dê°ì %s ì¤ì %sê°ë¥¼ 먹ìë¤.%n", total, fruit, eat); // %f float pi = 3.14159f; System.out.printf("íì´ê°ì %f ì ëë¤.%n", pi); System.out.printf("íì´ê°ì %.3f ì ëë¤.%n", pi); // í¬ë§· íìì Stringììë ì¬ì©í ì ìë¤. String str = String.format("%dê°ì %s ì¤ì %sê°ë¥¼ 먹ìë¤.%n", total, fruit, eat); System.out.println(str); } }