Java Vector copyInto() MethodThe copyInto() method of Java Vector class used to copy the elements of the vector which is in use into the specified array. In this, the position of the elements is the same in both the vector and an array. Syntax:Following is the declaration of copyInto() method: Parameter:
Returns:The copyInto() method has return type void so, it does not return anything. Exceptions:NullPointerException- This method has thrown an exception if the specified array is null. IndexOutOfBoundsException- This method has thrown an exception if the specified array is unable to hold all the components of this vector. Compatibility Version:Java 1.2 and above Example 1:Test it NowOutput: Elements in an array are: 1 2 3 4 5 Example 2:Test it NowOutput: Elements of the Array: Rahul Vijay Shyam Rohan Example 3:Test it NowOutput: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at java.base/java.lang.System.arraycopy(Native Method) at java.base/java.util.Vector.copyInto(Vector.java:200) at myPackage.VectorCopyIntoExample3.main(VectorCopyIntoExample3.java:12) Next TopicJava Vector |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India