Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Prefix and Postfix operator question



There doesn't seem to be any difference in the output when I change the prefix to the postfix operator for the following code:

public class inc

{

public static void main(String[]args)throws Exception

{

for(int val=1; val< 11; val++) //when I change it to ++val the output is the
                               //same

{

System.out.println(val);

}


}

}

Why use one or the other if there is no difference in output?

Thank you from Von, a struggling Java student