+1  A: 

You define an array in a constructor just like you would any other variable. So, it would look something like:

// define an array of size 3
String[] contactListNames = new String[3]; 

The reason you are getting exceptions is because you don't actually initialize the array. You declare it but you never set it to a value (or give it a size). You should post the stack trace of the error but I suspect it's a NullPointerException.

Jeff Storey
+2  A: 

To define an array in a constructor you can do something along these lines,

// if values are predefined, you can explicitly fill the array
String[] contacts = {"Bill Gates", "Steve Jobs", "Jon Skeet"};

// or this way, both will work.
String[] contacts = new String[2];

Looking at JList from the Java Doc's you can most certainly pass in an array to JList

 String[] data = {"one", "two", "three", "four"};
 JList dataList = new JList(data);

You are getting NullPointerException because the array, contactListNames is not initialized, you would need to initialize it.

Anthony Forloney
ok i initialized it in the constructor and changed the code in te question to match what it looks like now. unfortunately im still getting that error. should i initialize it where my variables are or in the constructor?
OVERTONE
It might not be visible to your `fillContactList` method, initialize the array inside that method or above in your class declaration, i.e. below the line, `public class MyClass` and see what happens.
Anthony Forloney
YES!!!! you spectacular genius! defining it outside the constructor as a set size worked perfectly.now i gotta get it working with sql..thanks again mate,
OVERTONE
Not a problem, also if you already know the size of the array you wish to fill, it might be good practice to set up your loop to read, `for(int i = 0; i < contactListNames.length; i++)`
Anthony Forloney
A: 

Then in my constructor i have the Jlist defined to fill itself with the contents of the array

String[] contactListNames = new String[5];
JList contactList = new JList(contactListNames);
fillContactList();

What you're doing here is creating new local variables that are shadowing the ones defined in your class. Change it to:

 contactListNames = new String[5];
 contactList = new JList(contactListNames);
 fillContactList();
JRL