fork download
  1. import java.util.Arrays;
  2.  
  3. class Array<E> {
  4.  
  5. private E[] data;
  6. private int size;
  7.  
  8. public Array(int size, E[] data)
  9. {
  10. this.size=size;
  11. this.data = Arrays.copyOf(data, size);
  12. }
  13.  
  14. public String toString()
  15. {
  16. String s=new String();
  17. for(int i=0; i<size; i++) s+=data[i]+" ";
  18. return s;
  19. }
  20. }
  21.  
  22. public class Main {
  23.  
  24. public static void main(String[] args) {
  25. // TODO Auto-generated method stub
  26. Integer A[]= {1, 3, 5, 7};
  27. Array<Integer> niza=new Array<Integer>(4, A);
  28. System.out.println(niza.toString());
  29. }
  30.  
  31. }
Success #stdin #stdout 0.07s 2841600KB
stdin
Standard input is empty
stdout
1 3 5 7