public class count {
private static int countPositive(int[] elems) {
int positive = 0;
for (int i=0;i<elems.length;i++) {
if (elems[i] > 0){
positive++;
}
}
return positive;
}
public static void main(String[] args) {
for(int i=0;i<args.length;i++)
//int x =Integer.parseInt(args[i]);
//System.out.println(countPositive(new int[]));
}
}
here i want to convert every str "numbers" in int number,but i have no idea how to write it. Do i have to add another array to save these int numbers,and then call the countPositive? please offer some help
my purpose is to write a command line argument, and it give me a number of positive numbers,for example
> java count 1 2 3 4 5 -1 -2 -3
5
> java count 0 -1 -2 -3 -3 -4
0