applet初始化问题!简单 for(i=1;i<=buylist.size();i++)/////for(i=0;i<buylist.size();i++) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 该问题已解决,但又出现新的问题!我自己创建了一个实例并加到向量中去了!indent buy=new indent(); buy.setId("2"); buy.setbook("2"); buy.setauthor("2"); buy.setprice(2); buy.setnum(2); buylist.addElement(buylist);if(!buylist.isEmpty()){ for(i=0;i<buylist.size();i++) { indent current=new indent(); current=(indent)buylist.elementAt(i);//错误行 String id=current.getId(); String book=current.getbook(); String author=current.getauthor(); String price=Float.toString(current.getprice()); toolBar.add(new Label(id)); toolBar.add(new Label(book)); toolBar.add(new Label(author)); toolBar.add(new Label(price)); } }错误指向行current=(indent)buylist.elementAt(i);错误代码如下:java.lang.ClassCastException at bookclass.shopcar.init(shopcar.java:74) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source)我知道是类的匹配问题,但我看不出怎么就不匹配了!indent类的结构如下:public class indent { private String Id; //ID序列号 private String book; //书名 private String author; //作者 private float price; //金额 private int num; public indent() { Id = ""; book=""; author=""; price=0; num=0; } public String getId() { return Id; } public void setId(String newId){ this.Id = newId; } public String getbook() { return book; } public void setbook(String newbook) { this.book = newbook; } public String getauthor() { return author; } public void setauthor(String newauthor){ this.author = newauthor; } public float getprice() { return price; } public void setprice(float newprice) { this.price = newprice; } public int getnum() { return num; } public void setnum(int newnum) { this.num = newnum; } }还请高手指教 从数据库读取,创建JLabel jdk-6-doc.zip哪里下? 用VC进行3des加密,如果用java进行解密? drawImage()的问题 【请教】问一个关于时间的怪问题! 各位大哥救命呀!关于thinlet document ???? 请问Socket出错的问题。 谁知道用SOCKET在几台机器之间互传文件的程序框架? 启动Tomcat时报错,急需解决!!!! 请教网页中右击DOWNLOAD ALL功能的技术细节。 痛苦的初学者,错误接二连三:( 编译问题。
我自己创建了一个实例并加到向量中去了!
indent buy=new indent();
buy.setId("2");
buy.setbook("2");
buy.setauthor("2");
buy.setprice(2);
buy.setnum(2);
buylist.addElement(buylist);
if(!buylist.isEmpty()){
for(i=0;i<buylist.size();i++)
{
indent current=new indent();
current=(indent)buylist.elementAt(i);//错误行
String id=current.getId();
String book=current.getbook();
String author=current.getauthor();
String price=Float.toString(current.getprice());
toolBar.add(new Label(id));
toolBar.add(new Label(book));
toolBar.add(new Label(author));
toolBar.add(new Label(price));
}
}
错误指向行current=(indent)buylist.elementAt(i);错误代码如下:java.lang.ClassCastException
at bookclass.shopcar.init(shopcar.java:74)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我知道是类的匹配问题,但我看不出怎么就不匹配了!indent类的结构如下:
public class indent {
private String Id; //ID序列号
private String book; //书名
private String author; //作者
private float price; //金额
private int num;
public indent() {
Id = "";
book="";
author="";
price=0;
num=0;
}
public String getId() {
return Id;
} public void setId(String newId){
this.Id = newId;
} public String getbook() {
return book;
} public void setbook(String newbook) {
this.book = newbook;
} public String getauthor() {
return author;
} public void setauthor(String newauthor){
this.author = newauthor;
} public float getprice() {
return price;
} public void setprice(float newprice) {
this.price = newprice;
} public int getnum() {
return num;
} public void setnum(int newnum) {
this.num = newnum;
}
}
还请高手指教