Java Stack Usage endsWithIgnoreWhiteSpace(String decl, String token)

Here you can find the source of endsWithIgnoreWhiteSpace(String decl, String token)

Description

ends With Ignore White Space

License

Open Source License

Declaration

public static boolean endsWithIgnoreWhiteSpace(String decl, String token) 

Method Source Code

//package com.java2s;

import java.util.Stack;

public class Main {
    /** @METHOD */
    public static boolean endsWithIgnoreWhiteSpace(String decl, String token) {
        int index = decl.length() - 1;
        Stack<Character> stack = new Stack<Character>();
        for (int i = 0; i < token.length(); index--) {
            if (decl.charAt(index) == ' ' || decl.charAt(index) == '\t')
                continue;
            char c = decl.charAt(index);
            stack.push(c);/*from w w w .j  a v a 2 s  . c o  m*/
            i++;
        }

        int stack_sz = stack.size();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < stack_sz; i++) {
            Character elem = stack.pop();
            sb.append(elem.toString());
        }
        if (token.equals(sb.toString()))
            return true;
        return false;
    }
}

Related

  1. getBinary(long input)
  2. getOperands(Stack stack, int nOperands)
  3. getPermutationsRec(List permutations, byte[] order, List> remaining, int index)
  4. getPostOrder(List inOrderList)