Q:

Checking vowels in string array

This is the code I have written to count the amount of vowels in a string array:
int vowels = 0;
for (int x = 0; x < arrayInput.length; x++) {
    for (int a = 0; a < arrayInput[x].length(); a++){
        switch (arrayInput[x].charAt(a)){
            case 'A': vowels++;
            case 'a': vowels++;
            case 'E': vowels++;
            case 'e': vowels++;
            case 'I': vowels++;
            case 'i': vowels++;
            case 'O': vowels++;
            case 'o': vowels++;
            case 'U': vowels++;
            case 'u': vowels++;
            case 'Y': vowels++;
            case 'y': vowels++;
        }
    }
}

However, vowels always returns 0. Why?
Found the problem!
This code earlier in the program:
String[] vowelArray = arrayInput;
for (int x = 0; x < vowelArray.length; x++) {
    vowelArray[x] = vowelArray[x].replaceAll("[AEIOUYaeiouy]", "_");
}
for (int x = 0; x < vowelArray.length; x++) {
    System.out.print(vowelArray[x] + " ");
}

Was changing the value of `arrayInput'
Does anyone know why?

A:

The code works fine, check if arrayInput is not empty/null and yes add break statements
    String[] arrayInput = {"This","is","random","string"};
    int vowels = 0;
    for (int x = 0; x < arrayInput.length; x++) {
        for (int a = 0; a < arrayInput[x].length(); a++){
            switch (arrayInput[x].charAt(a)){
                case 'A': vowels++;break;
                case 'a': vowels++;break;
                case 'E': vowels++;break;
                case 'e': vowels++;break;
                case 'I': vowels++;break;
                case 'i': vowels++;break;
                case 'O': vowels++;break;
                case 'o': vowels++;break;
                case 'U': vowels++;break;
                case 'u': vowels++;break;
                case 'Y': vowels++;break;
                case 'y': vowels++;break;
            }
        }
    }
    System.out.println(vowels);

Output
5

Input
"This"   "is"    "random"    "string"
   -      -        -  -          -

