(a) 
// Create an object array
Object args[] = { "File not found.", new Integer(2) };
// Format the message
System.out.println(
   java.text.MessageFormat.format("Error: {0} (Code {1})",args));

(b)
System.Console.WriteLine("Error: {0} (Code {1})", "File not found.", 2);

Example 4: String formatting. (a) in Java; (b) in C#.

Back to Article