fork download
  1. //ArrayCombine.java
  2.  
  3. class ArrayCombine{
  4. public static int combine(int[] array1, int[] array2){
  5. int[] newArray = new int[array1.length + array2.length];
  6. int curPos;
  7. for(int i = 0; i < newArray.length - 3; i++){
  8. newArray[curPos] = array1[i];
  9. curPos++;
  10.  
  11. }
  12. for(int j = 0; j < newArray.length - 3; j++){
  13. newArray[curPos] = array2[j];
  14. curPos++;
  15.  
  16. }
  17. return newArray;
  18. }
  19. public static void main(String args[]){
  20.  
  21. int[] array1 = { 1, 2, 3 };
  22. int[] array2 = { 4, 5, 6 };
  23. int[] newArray = combine(array1, array2);
  24. System.out.println(newArray);
  25. }
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:17: incompatible types
found   : int[]
required: int
		return newArray;
		       ^
Main.java:23: incompatible types
found   : int
required: int[]
		int[] newArray = combine(array1, array2);
		                        ^
2 errors
stdout
Standard output is empty