Java Example - String Formatting
The following example demonstrates formatting a string through the format() method, and you can also specify a region to format ():
//StringFormat.java 文件import java.util.*;public class StringFormat{ public static void main(String[] args){ double e = Math.E; System.out.format("%f%n", e); System.out.format(Locale.GERMANY, "%-10.4f%n%n", e); //指定本地为德国(GERMANY) }}
The output result of the above code example is:
2.7182822,7183