I'm having some Trouble with an ArrayList. All i need to do is to pass a filled ArrayList to another Class so i can use the Values of the ArrayList there. Here's a snippet from the first Class:
public ArrayList<String> collCollect = new ArrayList<String>();
for (int i = 0; i < ListModel.size(); i++) {
collCollect.add(ListModel.get(i).toString());
}
System.out.println(collCollect);
Till this Part everything is going quite well (i stripped the rest of the Code!)
Now comes the tricky Part! This is the Second Class:
ClassA pMain;
DecimalFormat f = new DecimalFormat("#0.00");
public ArrayList<String> listContent = new ArrayList<String>(pMain.collCollect);
DefaultListModel<String> ListModelNew = new DefaultListModel<String>();
public static void main(String args[]) {
for (int i = 0; i < listContent.size(); i++){
ListModelNew.add(i, listContent.get(i));
}
}
Everytime the ClassB is loaded i get a NullPointerException from the Line where the reference to the Array in pMain is made.
Any help would be appriciated...i'm unable to get the Values from ClassA ArrayList to ClassB -.-
pMain.ClassA pMail = new ClassA();