处理bug
public class HelloWorld{ public static void main(String[] args){ int num = 999; int count = 0; while(num > 1) { num = num / 10; count += 1; } System.out.println("它是个" + count +"位的数!"); } }
有漏洞,万一 “num == 0”,该怎么办呢?
public class HelloWorld{ public static void main(String[] args){ int num = 999; int count = 0; while(num > 1) { num = num / 10; count += 1; } System.out.println("它是个" + count +"位的数!"); } }
有漏洞,万一 “num == 0”,该怎么办呢?
2017-11-09
举报