Java Array newInstance() MethodThe getInstance() method of Array class is used to create a new array with the specified component type and dimensions. If componentType is a class of type non-array or interface, the new array has dimensions.length dimensions and componentType as its component type. SyntaxParametercomponentType - the object representing the component type of the new array dimensions - an array of int representing the dimensions of the new array Returnsthe new array ThrowsNullPointerException IllegalArgumentException ArrayIndexOutOfBoundsException - NegativeArraySizeException Example 1Test it NowOutput: Array[0][0] = javaTpoint Array[1][1] = .Net Array[2][2] = c# Example 2Test it NowOutput: [0, 1, 2, 3] Next TopicJava Array Class |
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