hi all, i'm having a bit of trouble with this code, what i want it to do is just return a
string array of strings where possible, its ok if the string array is empty when returned, since there are situations in my project where its supposed to be empty. I keep getting either a IndexOutOfBounds Exception or a NullPointerException when i return the string array. Can anyone help?
class InfoLib
{
String data;
InfoLib next;
public InfoLib(String data)
{
this.data = data;
this.next = null;
}
}
public String[] getallinfo()
{
//this is here to initialise the string array
String[] summary = new String[0];
//count is a global to be passed in
if (count > 0)
{
summary = new String[count];
int x = 0;
//assigns a link list head, and traverse through the
//list and get info
InfoLib llhead;
if (! isEmpty())
{
while (llhead.next != null)
{
summary[x] = llhead.data;
llhead = llhead.next;
x = x + 1;
}
summary[x] = llhead.data;
}
}
return summary;
}