What is the output of the following code?
System.out.printf("%<s, %<s, %<s, %2$s, and %<s", "Java", "Javascript");
java.util.MissingFormatArgumentException
The statement will throw a java.util.MissingFormatArgumentException because it uses relative indexing for the first format specifier:
public class Main { public static void main(String[] args) { System.out.printf("%<s, %<s, %<s, %2$s, and %<s", "Java", "Javascript"); }// w w w .ja v a 2 s . co m }