全国计算机二级Java语言程序设计辅导22
求学快递网计算机等级考试专题重点推荐:2016年计算机一级考试报考时间 、2016年计算机一级考试证书领取时间、2016年计算机一级考试报考指南、2016年计算机一级考试大纲、2016年计算机一级考试政策、2016年计算机一级考试报考条件、2016年计算机一级考试科目等最新新闻资讯。
我们知道输出格式化数字可以使用printf()和format()方法。String类使用静态方法format()返回一个String对象而不是PrintStream对象。
String类的静态方法format()能用来创建可复用的格式化字符串,而不仅仅是用于一次打印输出。如下所示:
System.out.printf("The value of the float variable is " + "%f, while the value of the integer " + "variable is %d, and the string " + "is %s", floatVar, intVar, stringVar);
你也可以这样写
String fs; fs = String.format("The value of the float variable is " + "%f, while the value of the integer " + "variable is %d, and the string " + "is %s", floatVar, intVar, stringVar); System.out.println(fs);
关注求学快递网计算机等级考试专题,帮你了解最新的2016年计算机一级考试资讯服务和2016计算机一级考试成绩查询,让你轻松备考计算机等级考试!
求学快递网计算机等级考试专题的小编们根据网民搜索喜爱,第一时间公布2016年计算机一级模拟试题、2016年计算机一级考试应试技巧、计算机一级考试历年真题、2016年计算机一级考试章节复习供广大求学爱好者学习使用,欢迎继续关注求学快递网计算机等级考试专题,并给我们提供宝贵的意见!