I am storing data in class object from array List like
MyClass[] obj = list.toArray(new myclass[0]);
if i want to append ArrayList data into MyClass object. what should i need to do? i want to do somethink like
obj = obj.append(list);
I am storing data in class object from array List like
MyClass[] obj = list.toArray(new myclass[0]);
if i want to append ArrayList data into MyClass object. what should i need to do? i want to do somethink like
obj = obj.append(list);
The length of an array is immutable in java. This means you can't change the size of an array once you have created it. So if you don't know the final size of the array you can't do what you want using Array.
When you do:
MyClass[] obj = list.toArray(new myclass[0]);
You are creating an Array with size=1. Then you can't add elements.
Using List instead of Array could be a good solution.
I think you are mistaken ArrayList with array.
ArrayList is a raw type meaning it needs parameter to instantiate like:
ArrayList<String> arrayList = new ArrayList<String>();
which creates an empty ArrayList which will contain String.
You can add String by using arrayList.add("Something");. Now your array contains 1 element (String).
On the other hand assuming list is an ArrayList list.toArray() method will return an array (and does not take any argument). I don't think you want something like this.