-1

Main

import java.util.Scanner;

public class JT1{
    public static void main(String args[]){     
      String CopyArgs[] = new String[args.length];
      for(int i = 0; i < args.length; i++) {
         CopyArgs[i] = args[i]; 

     }
for (int i = 0; i < CopyArgs.length; i++) {
System.out.println(CopyArgs[i]); 
}
for (int j = 0; j < CopyArgs.length; j++) 
    System.out.println(CopyArgs[j] + " is " + CopyArgs[j].length() + " characters ");

//Method that uses CopyArgs to scan every single charAt and find the number of vowels for each word
MetodiJT1.NumVocali(CopyArgs[]);
}
}    

Method class

public class MetodiJT1  {

public static void NumVocali (String a[]){
    int n = 0;
    for(int l=0; l < a.length; l++){
        for(int k=0; k < a[l].length(); k++){
            switch (a[l].charAt(k)){
                 case 'a':
                 case 'e':
                 case 'i':
                 case 'o':
                 case 'u':
                    n++;
                    break;
                 }
        }
    }
    System.out.println(n);
}   
}

I don't know how to fix this error, I feel like I'm missing something

     JT1.java:18: error: '.class' expected
     MetodiJT1.NumVocali(CopyArgs[])
                                  ^        

JT1.java and MetodiJT1.java are two different classes and I'm trying to use NumVocali to print the number of vowels for every a[l].

drowny
  • 2,067
  • 11
  • 19
axaro1
  • 29
  • 1
  • 1
  • 3
  • Not the cause of the problem, but by convention, variables start with lower case letters. (`copyArgs` instead of `CopyArgs`) and the array indicator is usually placed on the type as well (`String[] args` instead of `String args[]`) – TiiJ7 Sep 08 '18 at 10:42
  • try give more details on your post please – JSmith Sep 08 '18 at 14:05

2 Answers2

0

Change MetodiJT1.NumVocali(CopyArgs[]); to MetodiJT1.NumVocali(CopyArgs);

benjamin c
  • 2,278
  • 15
  • 25
0

Send parameter to method with only name of variable. So change this line ;

MetodiJT1.NumVocali(CopyArgs[]);

With this line ;

MetodiJT1.NumVocali(CopyArgs);
drowny
  • 2,067
  • 11
  • 19