| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2267 人关注过本帖
标题:在jdk1.6下如何实现格式化输出?
取消只看楼主 加入收藏
恋恋枫情
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-8-1
收藏
 问题点数:0 回复次数:4 
在jdk1.6下如何实现格式化输出?

在jdk1.5环境下,可以用System.out.printf()实现格式化输出,貌似jdk1.6不支持哦。。
哪位大仙可以指点下

搜索更多相关主题的帖子: jdk 格式化 输出 环境 printf 
2007-08-01 16:35
恋恋枫情
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-8-1
收藏
得分:0 

System.out.printf()和C中的printf()的用法差不多吧

弱弱的问一下,这个System.out.format()在jdk1。6环境下貌似也不好用哦

2007-08-01 17:52
恋恋枫情
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-8-1
收藏
得分:0 
以下是引用弑神饕餮在2007-8-1 17:45:09的发言:

可以的 两种都可以 都一样 给你写一个很简单的小例子

public class A {
public static void main (String[] args) {
int i=1;
float j=2;
System.out.printf("i is %d\n",i);
System.out.format("j is %f\n",j);
}

}

执行通不过
出来的是:“Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method format(String, Object[]) in the type PrintStream is not applicable for the arguments (String, float)”

2007-08-01 17:55
恋恋枫情
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-8-1
收藏
得分:0 
以下是引用heilong在2007-8-1 18:15:51的发言:

可以啊`````````我用的就是JDK1.6


我的还是不行
显示:“Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)
The method format(String, Object[]) in the type PrintStream is not applicable for the arguments (String, float)

难道与rp有关

2007-08-01 18:31
恋恋枫情
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-8-1
收藏
得分:0 
以下是引用heilong在2007-8-1 18:35:19的发言:
那我就不知道了,不过用这个干吗呢?好像没什么用吗?
直接System.out.println()就可以了啊````````

55555。。
数据输出有精度要求的嘛

2007-08-01 19:07
快速回复:在jdk1.6下如何实现格式化输出?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015207 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved