The program will print out:
value is: 5 value is: 15
Look at this program fragment. Click inside the program to see how it works.
int count = 0; // statement 1 System.out.println( count ) ; // statement 2 count = count + 1; // statement 3 System.out.println( count ) ; // statement 4
Here is how the program works:
count
.count
.count
,
adds 1 to it, and puts the
result back in count
.count
.When the fragment runs, it writes:
0 1
Think of a way to write 0, 1, and 2.