How will you convert an ArrayList to Arrays?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
What is the difference between interface & abstract class?
What is an object?s lock? Give name of object?s that have locks?
Name few java util classes introduced with java 8 ?
Is null a string or object in java?
Explain the role played by Java Virtual Machine in Java Programming?
I want to print “hello” even before main is executed. How will you acheive that?
What is the difference between inner class and nested class?
How do you add an element to a set in java?
What is java console application?
which one the better thread emplemented thread or extended ?
Why declare Main() method as a static in java ?
What is the difference between overloading and overriding a function?
13 Answers eG Innovations, Infosys, TCS,