在jdk1.5环境下,可以用System.out.printf()实现格式化输出,貌似jdk1.6不支持哦。。
哪位大仙可以指点下
可以的 两种都可以 都一样 给你写一个很简单的小例子
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)”
可以啊`````````我用的就是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有关
执行通不过
出来的是:“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)”
程序是不会有问题的 估计是你的JDK的问题吧