fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] myArr = {1,2,3};
  13. Integer[] myCopy = Arrays.copyOf(myArr, myArr.length, Integer.class);
  14. System.out.println(myArr.length + "_" + myCopy.length);
  15. }
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:13: error: no suitable method found for copyOf(int[],int,Class<Integer>)
		Integer[] myCopy = Arrays.copyOf(myArr, myArr.length, Integer.class);
		                         ^
    method Arrays.copyOf(boolean[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(double[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(float[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(char[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(long[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(int[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(short[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.copyOf(byte[],int) is not applicable
      (actual and formal argument lists differ in length)
    method Arrays.<T#1,U>copyOf(U[],int,Class<? extends T#1[]>) is not applicable
      (no instance(s) of type variable(s) T#1,U exist so that argument type Class<Integer> conforms to formal parameter type Class<? extends T#1[]>)
    method Arrays.<T#2>copyOf(T#2[],int) is not applicable
      (cannot instantiate from arguments because actual and formal argument lists differ in length)
  where T#1,U,T#2 are type-variables:
    T#1 extends Object declared in method <T#1,U>copyOf(U[],int,Class<? extends T#1[]>)
    U extends Object declared in method <T#1,U>copyOf(U[],int,Class<? extends T#1[]>)
    T#2 extends Object declared in method <T#2>copyOf(T#2[],int)
1 error
stdout
Standard output is empty