Home > Java > javaTutorial > body text

Java Example - String Formatting

黄舟
Release: 2017-02-22 09:50:56
Original
1099 people have browsed it

//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)
   }}
Copy after login

The output result of the above code example is:

2.718282
2,7183
Copy after login

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template