int count = 0;while (i < 100) { if (String.valueOf(i).contains("9")) { System.out.println(i);count++;} i++;} System.out.println("整数中9出现的次数:" + count);