这样为什么错了
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
while(num/10!=0){
count++;
}
System.out.println("它是"+count+"位数");
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
while(num/10!=0){
count++;
}
System.out.println("它是"+count+"位数");
}
}
2016-04-12
每次运行,num的值都没有改变,
package test_01;
import java.util.Arrays;
public class Test01_02 {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 定义一个字符串数组
int num = 1234;
int count = 0;
while(num/10!=0){
num=num/10;
count++;
}
count+=1;//当只有一位数的话,就不会执行while语句
System.out.println("它是"+count+"位数");
}
}
举报