As the OP is a very new Java Programmer, I thought it might be be
helpful to give a small tutorial, as one might in beginners class.
The other's that have responded have been correct, but everyone has to
start somewhere.
OK. The section you don't understand has several integer variable,
which are the names of storage locations in the computer's memory.
I'll draw them out to show what they are storing (at the moment they
are empty):
.---. .---. .---. .---. .---.
| | | | | | | | | |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Now in Java, new variables are initialised to zero when the program
starts. (This is not true of all languages BTW).
I'll Set the values to those they hold after reading (say) 4 and
positioned at the comment:
//This is the section I don't really understand
.---. .---. .---. .---. .---.
| 4 | | 1 | | 0 | | 0 | | 0 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Now, moving on a couple of lines, we start the loop:
for (int c =2; c < numToPrint; c++) {
We can see thatc < numToPrint is true so we continue:
.---. .---. .---. .---. .---.
| 4 | | 1 | | 0 | | 0 | | 2 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
The next two lines get executed:
lastlast = last;
last = current;
.---. .---. .---. .---. .---.
| 4 | | 1 | | 1 | | 0 | | 2 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Then the next line is:
current = lastlast + last;
.---. .---. .---. .---. .---.
| 4 | | 1 | | 1 | | 0 | | 2 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Then: System.out.println(current);
This outputs "1"
At the bottom of the loop we increment c by one:
.---. .---. .---. .---. .---.
| 4 | | 1 | | 1 | | 0 | | 3 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
and then back to the top to compare c < numToPrint which is still
true, thus we continue:
The next two lines get executed:
lastlast = last;
last = current;
.---. .---. .---. .---. .---.
| 4 | | 1 | | 1 | | 1 | | 3 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Then the next line is:
current = lastlast + last;
.---. .---. .---. .---. .---.
| 4 | | 2 | | 1 | | 1 | | 3 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
Then: System.out.println(current);
This outputs "2"
At the bottom of the loop we increment c by one:
.---. .---. .---. .---. .---.
| 4 | | 2 | | 1 | | 1 | | 4 |
'---' '---' '---' '---' '---'
numToPrint current last lastlast c
and then back to the top to compare c < numToPrint which is now
false, so the program ends.
Hopefully that helped you understand the code a bit more?
(Courtesy of emacs picture edit mode and a cold beer!)
a = bmeans that you're assigning valuebto varaand not the other way around.