Creating arraylist inside a constructors signature.
807588May 27 2009 — edited May 27 2009Hi.
I'm relativly new to java and I wanted to ask how I can create an arraylist in a constructors signature.
I'm using BlueJ.
Here is some sample code.
**********************REST OF CODE OMMITED************************
CLASS A
private ArrayList<String> normalstep; // Hold the Strings for fullstep.
private ArrayList<String> fullstep; // Hold the Strings for fullstep.
private ArrayList<String> halfstep; // Hold the strings for halfstep.
private MotorGui motorgui
//private String array; // The name of the arrray to use.
private ArrayList myArray; // The actual object of the array to use.
private String mn;
public static void main(String args[])
{
//Robonet Karel = new Robonet();
}
// CommGui commGui)
// {
// this.commGui = commGui;
//
public Robonet(String mn,MotorGui motorgui,int p,ArrayList array)
{
normalstep = new ArrayList();
fullstep = new ArrayList();
halfstep = new ArrayList();
**************REST OF CODE OMMITED**************
Then in class B I create an instance of class A
CLASS B
**************REST OF CODE OMMITTED****************
private Robonet robot = new Robonet("01",this,THEARRAYLIST);
*************REST OF CODE OMMITTED*******************
So.... robot should have "01",this,and an arraylist
How?
Please tell me if you need more info.
Thanks in advance.
Simmi