import java.text.MessageFormat;
import java.util.Scanner;
public class MessageFormatEx {
	
	public static void main(String[] args) {
		// MessageFormat
		// : ๋ฌธ์์ด ํ์์ ๋ง๋ค๊ณ , ๋ฌธ์์ด์ ๋ฐ๋ผ ๋ค์ด๊ฐ ์๋ฆฌ๋ฅผ
		//   {k} ๋ก ํ์ํ์ฌ ํ์์ ์ง์ ํ๋ค. (k : 0~)
		//   \n : ํ ์ค ๊ฐํ(์ํฐ)
		//   \t : ํญ
		
		String text= "์์ด๋ : {0}\n๋น๋ฐ๋ฒํธ : {1}";
		Scanner sc = new Scanner(System.in);
		System.out.print("์์ด๋ : ");
		String id = sc.nextLine();
		System.out.print("๋น๋ฐ๋ฒํธ : ");
		String pw = sc.nextLine();
		String login = MessageFormat.format(text, id, pw);
		// * ... : ๊ฐ๋ณ ๋งค๊ฐ๋ณ์
		// ๊ฐ๋ณ ๋งค๊ฐ๋ณ์๋ ๋งค๊ฐ๋ณ์์ ๊ฐ์๋ฅผ ๋ณํ์ํค๋ฉด์ ์ฌ์ฉํ  ์ ์๋๋ก ํด์ฃผ๋ ๊ธฐํธ
		// ์ ๋ฌ ๋ฐ๋ ๋ฉ์๋์์๋ ๊ฐ๋ณ ๋งค๊ฐ๋ณ์๋ฅผ ํ๋์ ๋ฐฐ์ด๋ก ์ ๋ฌ๋ฐ๋๋ค.
		// ๋ง์ง๋ง ๋งค๊ฐ๋ณ์์ ์ ์ํด์ผํ๋ค.
		
		
		System.out.println(login);
		System.out.println();
		
		String[] studentInfo = {"๊น์กฐ์", "25ํ๋ฒ", "์ปดํจํฐ๊ณตํ๊ณผ", "20์ด"};
		String studentFormat = "์ด๋ฆ : {0} \n"
						     + "ํ๋ฒ : {1} \n"	
						     + "์ ๊ณต : {2} \n"	
						     + "๋์ด : {3} \n"	
				      		 ;
		String student = MessageFormat.format(studentFormat, studentInfo);
		System.out.println(student);
		sc.close();
	}
}
Java
๋ณต์ฌ



