首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA基础02_Java程序设计构造00_格式化输出

2012-09-03 
JAVA基础02_Java程序设计结构00_格式化输出?public class PrintfTest1 { public static void main(String[

JAVA基础02_Java程序设计结构00_格式化输出

?

public class PrintfTest1 { public static void main(String[] args) { double salary = 10000.0 / 3; int age = 10; String name = "huahua"; System.out.printf("name is %s. Age is %d.%n", name, age); System.out.printf("salary is %f ", salary); } }?

public class PrintfTest2 { public static void main(String[] args) { double salary = 10000.0 / 3; int age = 10; String name = "huahua"; System.out.printf("name is %2$s. Age is %1$d.%n", age, name); System.out.printf("salary is %,+9.1f ", salary); }}

?

热点排行