original code:
<small>
class ij
{
public static void main(String args[] )
{
int i =0;
int j =10;
tp: for (i= 0; i < j ; i++ )
//i = 0; i < j; i++
{
System.out.println("i = " +i);
i++;
System.out.println("After ++i: i = " +i + ", j = " + j);
if (i>j)
break tp;
j--;
System.out.println(i + " " + j);
System.out.println("
</small>
I'm a little new to
java so please feel free to correct me.
For each turn the forloop goes it increment the i variable by 2
and decrement the j variable by 1.
for (i= 0; i < j ; i++ ) // here i increments by one. and on the line
i++ i is incremented by 1. The if clause
if (i>j)
break tp;
j--;
doesn't do what it's suppose to do... i think... either way j get decremented by one each turn leaving the final block i = 8 and j = 6
------------------
Preparing for the Java 2 Certification exam