I have made an arraylist in one class but when I pass it to another class it is empty. There are elements in one class but in another class it is empty.
Here is my code in one class.
System.out.println(mot);
Paint p=new Paint(mot, start );
Here is my code in another class
ArrayList<String> motif;
ArrayList<Integer> number;
NewJFrame j=new NewJFrame();
public Paint(ArrayList<String> motif,ArrayList<Integer> number) {
initComponents();
motif=new ArrayList();
number=new ArrayList<>();
j=new NewJFrame();
}
public void paint(Graphics g) {
System.out.print(j.mot);
}
Please tell me how to solve my problem of empty arraylist?
motifornumber? What isj.motor justmot?motif=new ArrayList();will make the passed arraylistmotifto be new instance of arraylist, and thus since its new , its empty.