This is what I am trying to do:
CountVowel.java
package lab2;
/**
*
* @author Shyam
*/
public class CountVowel implements Runnable {
String[] input;
int vowels = 0;
char ch;
public CountVowel(String[] args) {
input=args;
}
public void run() {
try {
for (int i = 0; i < input.length; i++) {
String s = input[i];
for (int j = 0; j < s.length(); j++) {
ch = s.charAt(j);
if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o'
|| ch == 'O' || ch == 'u' || ch == 'U')
vowels++;
}
}
System.out.println("Vowels : " + vowels);
} catch (Exception e) {
}
}
}
VowelThread.java
package lab2;
/**
*
* @author Shyam
*/
import java.io.IOException;
public class VowelThread {
public static void main(String[] args)
throws IOException {
for (String str : args) {
System.out.println(str);
}
Thread t1 = new Thread(new CountVowel(args));
t1.start();
}
}
I have tried different approach as below to enter string in cmd however I am not getting desire out put.
C:\Users\Shyam\Documents\NetBeansProjects\lab2\src>java VowelCounter hello hello see you in
Error: Could not find or load main class VowelCounter
C:\Users\Shyam\Documents\NetBeansProjects\lab2\src>javac -cp . lab2\VowelThread.java hello hello see you in london
error: Class names, 'hello,hello,see,you,in,london', are only accepted if annotation processing is explicitly requested
1 error
I would appreciate your help.