Home  >  Article  >  Java  >  Java Example - String Formatting

Java Example - String Formatting

黄舟
黄舟Original
2017-02-22 09:50:561088browse

//StringFormat.java file

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.718282
2,7183

The above is the Java example - string formatting content, more For related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn