This example will show the use of the MessageFormat class to format the message. With the help of this class you can paramerterize the message.

Java Code:
import java.text.MessageFormat;

public class MessageFormatExp {

	public static void main(String[] args) {
		Object[] params = new Object[] { "Tom", "Dick" };
		String message = MessageFormat.format("{0} and {1} are good friends",
				params);
		System.out.println(message);
	}

}