How will you convert an ArrayList to Arrays?

Answers were Sorted based on User's Feedback



How will you convert an ArrayList to Arrays?..

Answer / vikneswarank

Using toArray() method for example

ArrayList arr_obj=new ArrayList()
arr_obj.add("viki");
arr_obj.add("siva");

Object[] obj=arr_obj.toArray();

for further Detail go to my website :
http://www.beexpert.co.in/

Is This Answer Correct ?    11 Yes 2 No

How will you convert an ArrayList to Arrays?..

Answer / tapan kumar kundu

Using toArray() method for example

ArrayList arr_obj=new ArrayList()
arr_obj.add("viki");
arr_obj.add("siva");

Object[] obj=arr_obj.toArray();

for further Detail go to my website :
http://www.beexpert.co.in/

Is This Answer Correct ?    6 Yes 0 No

How will you convert an ArrayList to Arrays?..

Answer / 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

How will you convert an ArrayList to Arrays?..

Answer / ramesh

ArrayList arr_obj=new ArrayList()
arr_obj.add("viki");
arr_obj.add("siva");

Object[] obj=arr_obj.toArray();

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What does it mean to be immutable?

0 Answers  


Which programming language is most secure?

0 Answers  


What is the unit of plancks constant?

0 Answers  


What do you understand by looping in java? Explain the different types of loops.

0 Answers  


Can you achieve runtime polymorphism by data members?

0 Answers  






Why for each loop is used?

0 Answers  


How do you sort a list in java?

0 Answers  


Can we create a constructor in abstract class?

0 Answers  


How does final modifier work?

1 Answers   Tech Mahindra,


What does sprintf return?

0 Answers  


What is a flag variable?

0 Answers  


Why singleton is not thread safe?

0 Answers  


Categories