Java 实例 - 字符串格式化

Java 教程 · 2019-02-10 09:29:23

以下实例演示了通过 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.CHINA , "%-10.4f%n%n", e); //指定本地为中国(CHINA) } }

以上代码实例输出结果为:

2.718282
2.7183  

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

How to Think Like a Computer Scientist: Learning with Python

How to Think Like a Computer Scientist: Learning with Python

Allen B. Downey、Jeffrey Elkner、Chris Meyers / Green Tea Press / 2002-1-4 / USD 24.95

""How to Think Like a Computer Scientist"" is an introduction to programming using Python, one of the best languages for beginners. This is a Free Book -- you can download it from thinkpython.com. But......一起来看看 《How to Think Like a Computer Scientist: Learning with Python》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

SHA 加密
SHA 加密

SHA 加密工具