作者PsMonkey (痞子军团团长)
站内java
标题Re: [J2SE] 请问JOptionPane输出string变数的问题
时间Tue Apr 1 10:37:10 2008
※ 引述《Sanbeishuu (三杯鼠)》之铭言:
: show出这段 y阵列是string的
^^^^^^^^^^^^^^^^
应该说,y 是一个 String 阵列
还有,请注意大小写,即使是在文字叙述也一样
: String y[] = {truck.getKind(),sedan.getKind(),cat.getKind(),dog.getKind()};
: String message = String.format( "NO.1 is %d, NO.2 is %d, NO.3 is %d, NO.4 is
: %d", y[0],y[1],y[2],y[3] );
: JOptionPane.showMessageDialog(null, message);
: compile是过了 但是执行却出现这个问题
: 是因为不能使用是string的变数吗??
: D:\Java>java game
: Exception in thread "main" java.util.IllegalFormatConversionException: d !=
: java.lang.String
: at
: java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:399
: 2)
其他的,我想错误讯息应该很清楚的告诉你了
--
侃侃长论鲜窒碍 首页:
http://www.psmonkey.idv.tw
众目睽睽无心颤 Blog:
http://ps-think.blogspot.com
茕居少聊常人事
杀头容易告白难 欢迎参观 Java 版(@ptt.cc) \囧/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.20.164.67