Code example for Stack

0
    public TagContext(String tagName) {
        this.tagName = tagName;
    } 
     
    public static void init() { 
        currentStack.set(new Stack<TagContext>());
        enterTag("ROOT"); 
    } 
     
    public static void enterTag(String name) {
        currentStack.get().add(new TagContext(name));
    } 
     
    public static void exitTag() { 
        currentStack.get().pop();
    } 
     
    public static TagContext current() { 
        return currentStack.get().peek();
    }