Originally Posted by
sudesh
int low = 2;
int high = 1;
while (high < 10){
System.out.println(high);
int temp = high;
high = high + low;
low = temp ;
}
i am a beginner to java, having said that, in my head I compile the output as 1, 3, 4, 6 whereas complier says 1, 3, 4, 7.
What am i not understanding ? Also how is it possible to initialize 1 variable with anther, for example low = temp ?
You're program is doing what it should correctly. I would look at the logic of whats happening with each iteration. And I'm not sure what you mean by initialize. If you mean create a variable with another variable, Java is an Object oriented language, so I'm willing to bet you'll need an object or a class.