-10

After executing below program, print 5 hello java lines. so i know i++ is there print 10 lines.I need to what is duty of i+=2 in this program.

 class Example{
      public static void main(String args[]){
            for(int i=0; i<10; i+=2){
            System.out.println("Hello Java");
            }
       }
   }
OldProgrammer
  • 12,050
  • 4
  • 24
  • 45
  • 5
    increments i by 2 each iteration. Print out i and you will see. – OldProgrammer Feb 08 '20 at 15:32
  • 1
    https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op1.html, --- Please read: [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) --- http://idownvotedbecau.se/noresearch/ – Turing85 Feb 08 '20 at 15:32

1 Answers1

0
for(int i = 0; // i is an variable integer, which is 0 from the start
    i < 10;    // if i is 10 or above, the loop is finished, else the code runs
    i += 2)    // after the code is ran, 2 will be added to the variable i 
{/*...*/}
lue
  • 449
  • 5
  • 16