public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
for(int i=1;;i=i*10){
if(num>=i){
count=count+1;
}else{
System.out.println("它是个"+count+"位的数!");
break;
}
没毛病,for的参数可以为空