abstract public class Abstract {
protected ArrayList<Integer> list=new ArrayList<Integer>();
protected ProblemEncoder problemEncoder = new Aproblem(list); public Abstract() throws Exception {
System.out.println("@ MAOS-TOY V1.0.000, all right reserved.");
System.out.println("Start Module ["+getClass().getName()+"]");
list.add(2);
list.add(3);
list.add(2);
}
}子类:
public class De extends Abstract{
public De() throws Exception {}
public static void main(String[] args) {
try { AbstractSwarm swarmBody = new DEPS();
swarmBody.run(args);
}
catch (Exception e) {
System.out.println("@ERROR: "+e.toString());
e.printStackTrace();
System.exit(-1);
}
}这个list的初始化到底在哪儿定义才是正确的?
protected ArrayList<Integer> list=new ArrayList<Integer>();
protected ProblemEncoder problemEncoder = new Aproblem(list); public Abstract() throws Exception {
System.out.println("@ MAOS-TOY V1.0.000, all right reserved.");
System.out.println("Start Module ["+getClass().getName()+"]");
list.add(2);
list.add(3);
list.add(2);
}
}子类:
public class De extends Abstract{
public De() throws Exception {}
public static void main(String[] args) {
try { AbstractSwarm swarmBody = new DEPS();
swarmBody.run(args);
}
catch (Exception e) {
System.out.println("@ERROR: "+e.toString());
e.printStackTrace();
System.exit(-1);
}
}这个list的初始化到底在哪儿定义才是正确的?
list.add(2);
list.add(3);
list.add(2);
传递这个参数,
protected ProblemEncoder problemEncoder = new Aproblem(list);
才能用不是