3.2 Stack的用法
马克-to-win:Stack称为“后入先出”(LIFO)集合。
例:3.2.1
import java.util.*;
public class TestMark_to_win {
static String[] months = { "一", "二", "三" };
public static void main(String[] args) {
Stack stk = new Stack();
for (int i = 0; i < months.length; i++)
stk.push(months[i] );
System.out.println("stk = " + stk);
System.out.println("弹出 elements:");
while (!stk.empty())
System.out.println(stk.pop());
}
}
更多请见:https://blog.csdn.net/qq_44639795/article/details/103079646