[java]
package test;
import java.util.LinkedList;
public class test2 {
static LinkedList link =null;
public static void main(String args[])throws Exception {
link = new LinkedList();
push(1);
int d =top();
System.out.println(d);
pop();
pop();
}
static boolean push(int i){
link.addFirst(i);
return true;
}
static int top(){
int get = 0;
try{
get = link.getFirst();
}catch(Exception e){System.out.println("没有数据");}
return get;
}
static boolean pop(){
try{
link.removeFirst();
}catch(Exception e){
System.out.println("没有数据");
return false;
}
return true;
}
}