How will you convert an ArrayList to Arrays?

Answer Posted / vikas

using toArray() method.
example:

ArrayList<Integer> al = new ArrayList<Integer>();
al.add(1);
al.add(5);
al.add(8);
al.add(10);

//Get the array
Integer tempArray = new Integer[al.size()];
tempArray = al.toArray(tempArray);

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why destructor is not used in java?

739


Explain the difference between throw and throws in java?

776


What is data member in java?

681


What is difference between classpath and path variables in java?

871


What is main method?

768


What is the point of polymorphism java?

750


Is null a string?

763


What is the difference between keyword and identifier?

787


How do you reverse sort a list in java?

731


What are the three types of design patterns?

729


How do you clear an arraylist in java?

704


What is files manifesting?

1959


Is main is a keyword?

789


What is the difference between the paint() and repaint() methods in java programming?

881


How do you sort in ascending order in java?

677