我觉得可以这样啊!
public class HelloWorld{
public static void main(String[] args){
int num = 999;
System.out.println("它是个"+(num+"").length()+"位的数!");
}
}
public class HelloWorld{
public static void main(String[] args){
int num = 999;
System.out.println("它是个"+(num+"").length()+"位的数!");
}
}
2022-02-24
import java.util.Scanner; public class Demo415 { public static void main(String[] args) { int num = 999; System.out.print("请输入一个小于10位的数:"); num = new Scanner(System.in).nextInt(); int count = 0; if (num < 1000000000) { System.out.println(String.format("%d它是个%s位的数!", num, String.valueOf(num).length())); } } }
举报