控制台输入整数,请设计一个死循环,当用户输入非正数时停止输入。请给出用户输入的正整数个数(默认输入个数不超过2147483647)
public static void main(String[] args) {
int count = 0;
Scanner scanner = new Scanner(System.in);
//write your code here......
while(true){
if(scanner.nextInt()>0){
count++;
}else{
System.out.print(count);
break;
}
}