int x=0; int a=1; while(true){ x=(x+1)%10; a++; System.out.println(x); if(a==20) break; } 上面代码是让输出19次。