What is the use of toarray () in java?



What is the use of toarray () in java?..

Answer / Srijan Chaubey

The toArray() method in Java is used to convert a collection into an array. It returns an array containing all of the elements in this collection, or a subset if the collection implements the RandomAccess interface and a partial view is requested.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

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

1 Answers   HCL,


What is an object in java and how is it created?

0 Answers  


String and stringbuffer both represent string objects. Can we compare string and stringbuffer in java?

1 Answers  


What's the base class in java from which all classes are derived?

1 Answers  


explain me with a code snippet about the generation and handling of null point exceptions.

1 Answers  


Which browsers work with java?

1 Answers  


public class Test { public static void main(String[] args) { int countA = 0; int countB = 0; int countC = 0; int countD = 0; int countE = 0; int countF = 0; int countG = 0; int countH = 0; int countI = 0; int countJ = 0; int countK = 0; int countL = 0; int countM = 0; int countN = 0; int countO = 0; int countP = 0; int countQ = 0; int countR = 0; int countS = 0; int countT = 0; int countU = 0; int countV = 0; int countW = 0; int countX = 0; int countY = 0; int countZ = 0; } } Can anybody tell me any alternate solution(like loop or something) to automate this initialization process. Ex:- for(char chr='A';chr<='Z'; chr++) { (int) String "count"+chr = 0; }

1 Answers  


Nested classes VS Inner classes?

3 Answers   Infosys,


abstract class Demo { public void show() { System.out.println("Hello I am In show method of Abstract class"); } } class Sample extends Demo { public void show() { super.show(); System.out.println("Hello I am In Sample "); } } public class Test { public static void main(String[] args) { //I WANT TO CALL THE METHOD OF BASE CLASS IT IS POSSIBLE OR NOT CAN WE USE SCOPE RESOLUTION OPERATOR TO CALL OR JAVA NOT SUPPORTED THAT :: OPERATORE } }

3 Answers  


What is the difference between static (class) method and instance method?

1 Answers  


What are Encapsulation, Polymorphism and Inheritance?

5 Answers  


What is an example of a boolean?

1 Answers  


Categories