有点小失误,正确为:
public class Main {
public static void main(String[] args) {
int count = 1;
System.out.print(1);
for (int i= 2; i <= 100; ++i) {
if ((i & 1) == 1) {
System.out.print(" " + i);
++count;
}
}
System.out.println();
System.out.println("奇数个数为:" + count);
}
}