|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
package practice;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class Pra001 {
public static void main(String[] args) throws IOException {
String name = "Albert";
int age = 18;
double score = 100.0;
try (PrintWriter pw = new PrintWriter(new FileWriter(new File("info.txt")));) {
pw.printf("Name %s Age %d Score %d\n", name, age, score);
}
}
}
==========================================
Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4302)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2793)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2747)
at java.util.Formatter.format(Formatter.java:2520)
at java.io.PrintWriter.format(PrintWriter.java:905)
at java.io.PrintWriter.printf(PrintWriter.java:804)
at practice.Pra001.main(Pra001.java:17)
===============================================
请问大家,哪里错了(谢谢大家。 |
|