public class Fibonacci
{
public static void main(String[] args)
{
//初始化变量
int n0 = 1, n1 = 1, n2;
System.out.print(n0 + " " + n1 + " ");
//引入for循环依次执行三个表达式,限定i的取值范围为<10
for (int i = 0; i < 10; i++)
{
//下一个数是早先的两个数的和
n2 = n1 + n0;
System.out.print(n2 + " ");
//早先的第一个数成为早先的第二个数
n0 = n1;
//同时当前的数成为早先的数
n1 = n2; // And current number becomes previous
}
System.out.println(); // Terminate the line
}
}