Java Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Clarification on how this code works please

I am new to programming and I am learning Java and have come across this code but don't really understand how it works. The
part I particularly don't understand is in the main method why it is printIncrement(i++). Would appreciate if someone could explain to me. Thanks

public class Foo{

public static void printIncrement(int i)
{
System.out.println(++i);

}


public static void main(String [] args){

int i=1;
System.out.println(i);

while(i!=10)
{

printIncrement(i++);


}
}
}
Susie Y 5 months ago
  • Whitelisted Links