السلام عليكم ورحمة الله وبركاته
قمت بانشاء arraylist باسم collection عناصر هذه ال arraylist عبارة عن arraylist اخرى عناصرها Ellipse2D
static ArrayList <Ellipse2D> shpere=new ArrayList<Ellipse2D>(); static ArrayList <ArrayList> collections=new ArrayList<ArrayList>();
يعني كل موقع في مصفوفة الcollection يحتوي على sphere التي هي مصفوفة ايضا
وعندما قمت بكتابة هاد الكود لنسخ محتويات احد المواقع الى مصفوفة من نوع sphere ظهر عندي هذا الخطا
cannot find symbol method add(java.lang.Object)
وهذا هو الكود المستعمل للنسخ
if( e.getSource()==undo){
int num=collections.size(); //size of collection
collections.remove(num-1); //delet the last one
int loop=collections.get(num-2).size(); // return the size of arraylist ___Ellipse2D array ____ in the num-2 index
shpere.clear();
for(int m=0;m<loop;m++){
shpere.add(collections.get(num-2).get(m));
}
repaint();
}اليست الجملة التالية
collections.get(num-2).get(m)
المفروض ناتجها هو عبارة عن Ellipse2D
اذا اين الخطا ؟؟؟؟؟؟؟؟؟
وكمحاولة لحل المشكلة استخدمت
shpere.clear();
ArrayList <Ellipse2D>j=collections.get(num-2);
for(int m=0;m<loop;m++){
shpere.add(j.get(m));
}هنا لم يظهر خطا ولكن كان حجم المصفوفة j==0 اي انه لم يقم بعملية النسخ


