Greetings,
Still getting the hang of Java.
What am I doing wrong here?
import java.util.*;
public class DriveForm
{
public static void main(String[] args)
{
ArrayList alCustomerRecords;
InitArray(alCustomerRecords); <--- this is line 8
// panel2 mypanel2 = new panel2(alCustomerRecords);
// mypanel2.show();
}
public static void InitArray(ArrayList lalCustomerRecords)
{
lalCustomerRecords.add(new Customer("Alexandria","ALX"));
lalCustomerRecords.add(new Customer("Archways","ARC"));
}
}
Get this error;
DriveForm.java [8:1] variable alCustomerRecords might not have been
initialized
InitArray(alCustomerRecords);
^
1 error
Errors compiling DriveForm.
Brett Foster - 12 Dec 2004 21:38 GMT
*snip*
> ArrayList alCustomerRecords;
alCustomerRecords = new ArrayList();
> InitArray(alCustomerRecords); <--- this is line 8
*snip*
klynn47@comcast.net - 13 Dec 2004 07:24 GMT
Java requires that any local variable be initialized before it is used.
This is not true for instance or class variables. They will be
initialized to defaults if you don't initialize them in a constructor.
But for a local variable you must initialize it before you use it.