简体   繁体   中英

Eclipse console terminates codes

so i was doing some excercises(i won't go into details since it's not important) for Java and when i try to run this code here:

for(int i = 1;i == myInt;i++){//myInt is a pre-entered integer using Scanner
        int a = myInt % i;
        System.out.println(a);
}

the console ternimate it and display nothing.when i changed the code to this:

for(int i = 1;i < myInt;i++){
        int a = myInt % i;
        System.out.println(a);
}

the console display a list of "a" normally.I want to know what's wrong with the first code.I'm using eclipse,java 8 btw.

The first for loop will go through while i is equal to myInt. So if myInt is anything other than 1, the for loop will be skipped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM