java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
第MASTER1.write();
行,这是什么问题?.. 这是代码:
public class TryBehaviours extends Agent {
@Override
protected void setup(){
System.out.println("Agent" + this.getLocalName() + " Says: Hellowww" );
addBehaviour(new DataStore(this));
}
public class DataStore extends OneShotBehaviour{
public DataStore(Agent a) {
super(a);
}
@Override
public void action() {
try {
File f;
f = new File ("C:\\Users\\MR\\Desktop\\MyDatabase.xls");
WritableWorkbook MASTER1 = Workbook.createWorkbook(f);//MASTER is the name of our database
WritableSheet History_Table = MASTER1.createSheet("History_Table", 0);//names the first sheet as History_Table
MASTER1 = Workbook.createWorkbook(f);//makes the Database.xlx writable
Label L00 = new Label (0,0,"RUN#");
History_Table.addCell(L00);
MASTER1.write();
System.out.println("finished...");
MASTER1.close();
}
catch (WriteException | IOException ex) {
Logger.getLogger(TryBehaviours.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
这是我的入门班:
public class Starter extends Agent {
//int members = 50;
String[] name = new String[10];
AID[] AIDlist = new AID[10];
@Override
protected void setup() {
for (int i = 0; i < name.length; i++) {
name[i] = "Agent" + (i + 1);
AIDlist[i] = new AID(name[i], AID.ISLOCALNAME);
}
AgentContainer c = getContainerController();
AgentController[] a = new AgentController[10];
for (int j = 0; j < a.length; j++) {
try {
a[j] = c.createNewAgent(name[j], "TryBehaviours", null);
a[j].start();
System.out.println(" Created: " + AIDlist[j]);
} catch (Exception e) {
}
}
} }
a[j] = c.createNewAgent(name[j], "TryBehaviours", null);
行的我还收到与以下内容有关的错误:
@Override 公共无效run(){ if(target!= null){ target.run(); } }
我的代码有什么问题? ..此入门类在其他类上也很好用,但是对于这一类,它会引起问题和错误
答案 0 :(得分:1)
我认为问题与您用MASTER1.write();
调用的方法有关。
您可能需要为工作簿指定一个输出文件。