كيف أستطيع تعريف مصفوفة من الكائنات و للتوضيح
عندي Class من نوع صندوق كيف أستطيع عمل مصفوفة منها
كيف أستطيع تعريف مصفوفة من الكائنات و للتوضيح
عندي Class من نوع صندوق كيف أستطيع عمل مصفوفة منها
كيف عندك كلاس من نوع صندوق ؟؟؟
ممكن توضح سؤالك اكثر
You better use Vector and not Array especially if you do not know the number of objects you are going to store.
//create the vector Vector v = new Vector(); //your object Box b = new Box(); //store your object v.addElement(B); //when you want to get your object back,just cast it to its type Box myStoredBox = (Box) v.elementAt(index); //index is the index of the vector,example 0
Here is the solution using Arrays:
//create the array Box[] b = new Box[10]; this means you can store 10 objects of type Box //store a new Box in the first position b[0] = new Box(); //please note that array starts from 0 and NOT 1 //do the same for storing other objects by changing the index b[1] = new Box();
Ramadan Karim inshallah
Madani
عودا حميدا أخ مدنى - عمر
خالد المصرى
هذا الموضوع مغلق.