package com.fuxi.test.collection;
/**
* 利用堆栈输出递归序列的若干项:Fibonacci序列
* 堆栈是一种“先进后出”的特殊序列
*/
import java.util.Stack;
public class StackTest {
public static void main(String[] args) {
Stack<Integer> stack = new Stack<Integer>();
stack.push(new Integer(1));
stack.push(new Integer(1));
int k =1;
while(k<10){
Integer F1 = stack.pop();
int f1 = F1.intValue();
Integer F2 = stack.pop();
int f2 = F2.intValue();
Integer temp = new Integer(f2+f1);
System.out.println(temp.toString());
stack.push(temp);
stack.push(F2);
k++;
}
}
}