Substitute tokens in a String : MessageFormat « Development Class « Java






Substitute tokens in a String


import java.text.MessageFormat;

public class Main {
  public static void main(String[] argv) {

    Object[] params = new Object[] { "hello", "!" };
    System.out.println(MessageFormat.format("{0} world {1}", params));
  }
}
//hello world !

 








Related examples in the same category

1.Formatting a Message Containing a Number
2.Format message with Integer fillers
3.Use a custom format
4.Floating point numbers
5.Currency number format
6.Percent value format
7.Formatting a Message Containing a Time
8.Format Date() in short format
9.Format Date() value in medium format
10.Format Date() in long
11.Format Date value in full length
12.Use a custom format for Date value
13.Formatting a Message Containing a Date
14.Combine date value in a sentence
15.Date value short format
16.Medium length format for Date value
17.Long style format for Date value
18.Full length format for Date value