我在 BlueJ 上制作一个程序,但我无法确定代码中的错误

I was making a program on BlueJ but i am unable to figure was is wrong in the code

我用 BlueJ 做了一个程序来显示 1 到 100 的偶数。 但输出是从 8 到 100 的偶数。 所以我请求你帮助我纠正我的错误。为此,我会感谢你。

public class EvenNumbers1to100
 {
    public static void main(String args[])
    {
        int a;
        for(a=2;a<=100;a+=2)
        System.out.println(a);
    }
}

试试这个

int a = 100;

System.out.println("Even numbers from 1 to " + a);

for (int i = 1; i <= a; i++) {
  if (i % 2 == 0) {
   System.out.print(i + " ");
  }
}

如果你想把所有的数字都打印出来,你得循环一下