Search Results

Search found 1 results on 1 pages for 'user3677712'.

Page 1/1 | 1 

  • java:25: '.class' expected error while merging arrays

    - by user3677712
    Here is my code, it is asking me to call a class, I am confused as to do this. Noob to java, so any help would be greatly appreciated. line 25 is where the error occurs. This program is merging two arrays together into a new array. public class Merge{ public static void main(String[] args){ int[] a = {1, 1, 4, 5, 7}; int[] b = {2, 4, 6, 8}; int[] mergedArray = merge(a, b); for(int i = 0; i < mergedArray.length; i++){ System.out.print(mergedArray[i] + " "); } } public static int[] merge(int[] a, int[] b){ // WRITE CODE HERE int[] mergedArray = new int[a.length[] + b.length[]]; int i = 0, j = 0, k = 0; while (i < a.length() && j < b.length()) //error occurs at this line { if (a[i] < b[j]) { mergedArray[k] = a[i]; i++; } else { mergedArray[k] = b[j]; j++; } k++; } while (i < a.length()) { mergedArray[k] = a[i]; i++; k++; } while (j < b.length()) { mergedArray[k] = b[j]; j++; k++; } return mergedArray; } } This program is merging two arrays together into a new array.

    Read the article

1