Well, the title says it all but here's a little background info:
I've just begun studying Java from a beginners handbook in my native language. If there already exists a thread on this topic I apologize but I had no idea how to condense this question in a one or two word query for the search function.
So I'm busy with the chapter on loops and one of the exercices asks you to write a piece of code that would draw lines from left to right over a JPanel, all of them intersecting in the middle. You can give the increment between the lines in JTextField and execute the loop for drawing each line with a button or by hitting "enter/return". here's the code for the loop I wrote:
for (increment2 = 1; midden + increment2 <= hoogte; increment2 = increment2 + increment)
{
g.drawLine(0, midden + increment2, breedte, hoogte - increment2);
}
Now initially I set the value of increment2 as zero, but this had the effect that when I ran the complete code in eclipse, I just got a JFrame that froze, without the JPanel. I tinkered and cursed and tried a bunch of different things, to no avail. After staring at my screen with growing frustration for a while I started fixing my gaze on that zero, thinking about the fickle nature of this number throughout the history of mathematics and decided to eliminate any problems concerning zero (i know, pretty far fetched but after an hour or more of pulling your hair and cussing at the screen I was willing to try anything). I wasn't really expecting much but, what do you know... it worked! I had to make a modification of -1 to the original value of variable midden to keep the position of the lines in check with the exercice but all in all I was glad I got the damn thing working, albeit not in a very elegant way.
So much for the background info, back to the question now. Is there a reason why this variable can't initially be set to the value of zero and if yes, wich is it?