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

Is java ee a framework?

0 Answers  


Why does java doesnot support multiple inheritance?

5 Answers   TCS,


What is the benefit of inner classes in java?

0 Answers  


How the elements are organized in GridBagLayout?

1 Answers  


Which of these methods belong to Thread & Object class? join, yield, sleep, wait, notify

3 Answers   Ericsson,






What is the difference between Checked and Unchecked exception? Give some examples

2 Answers   Ness Technologies,


How static variable work in java?

0 Answers  


What are non-access modifiers?

2 Answers   Cognizant,


What is += mean in java?

0 Answers  


How to sort array of 0 and 1 in java?

0 Answers  


If we don’t want some of the fields not to serialize how to do that?

0 Answers  


what is the difference between Cpp And Java

15 Answers   Infosys,


Categories