这个为什么错啊?
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int i = 0;
if(num/10>0){num=num/10;i++;}
System.out.print(""+i);
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int i = 0;
if(num/10>0){num=num/10;i++;}
System.out.print(""+i);
}
}
2017-11-15
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int i = 0;
if(num/10>0){num=num/10;i++;} //多了一个分号
System.out.print(""+i); //应该写在分号内
}
}
//正确完整程序如下
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
if(num >=0&& num<=99999);
while(num!=0){
count++;
num/=10;
}
System.out.println("它是个"+count+"位的数!");
}
}
举报