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

Which method must be implemented by all threads?

982


What is indexof?

739


What is the purpose of the enableevents() method in java programming?

818


Can a singleton class be inherited?

722


Is singleton a bad practice?

817


State some situations where exceptions may arise in java?

852


Explain the scope of a variable.

858


what is the messsage u r going to get from an objectoriented programing?

1902


What is a short in java?

714


What is java and their uses?

783


Why declare Main() method as a static in java ?

833


Does sprintf allocate memory?

835


What is a generic code?

741


What classes of exceptions may be thrown by a throw statement?

754


What is jvm? Why is java called the platform independent programming language?

784