• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps help with arraylist

i have an arraylist with many elements i want to get some of this elements and put them in another arraylist
when i use array.get()
and then array.add()
it return many errors as nullpointerException and RuntimeException
 
Have a look on Stackoverflow. There are many examples, eg
this array deals with Strings,

ArrayList<String> stockList =newArrayList<String>();
stockList.add("stock1");
stockList.add("stock2");String[] stockArr =newString[stockList.size()];
 
i have an arraylist with many elements i want to get some of this elements and put them in another arraylist
when i use array.get()
and then array.add()
it return many errors as nullpointerException and RuntimeException

Null pointer exception means that the reference "array" was never instantiated. You can do this by calling array = new ArrayList<Some Class Name that you are storing here>(); http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
 
Back
Top Bottom