Java examples for Language Basics:Number Format
Reordering output with argument indices.
public class Main { public static void main(String[] args) {/*w ww. ja v a 2 s . c o m*/ System.out.printf( "Parameter list without reordering: %s %s %s %s\n", "first", "second", "third", "fourth"); System.out.printf( "Parameter list after reordering: %4$s %3$s %2$s %1$s\n", "first", "second", "third", "fourth"); } }