栈
Stack是一种后进先出的数据结构
Stack<String> s = new Stack<String>();
//将内容压入栈
s.push("A");
s.push("B");
s.push("C");
//读取栈顶内容,不移除
String str = s.peek();
//弹出栈顶元素
String str1 = s.pop();
//搜索元素和栈顶的距离
int index = s.search("A");
empty()检测栈是否为空
Stack是一种后进先出的数据结构
Stack<String> s = new Stack<String>();
//将内容压入栈
s.push("A");
s.push("B");
s.push("C");
//读取栈顶内容,不移除
String str = s.peek();
//弹出栈顶元素
String str1 = s.pop();
//搜索元素和栈顶的距离
int index = s.search("A");
empty()检测栈是否为空