private static List<Token> generatePostfix(List<Token> infix) {
		Stack<Token> stack = new Stack<Token>();
		List<Token> exp = new ArrayList<Token>();

		for (int i = 0; i < infix.size(); i++) {

			Token current = infix.get(i);

			/*
			 * If the current character is an operand: add it to the end of the
			 * postfix expression.
			 */
			if (current.isOperand()) {
				exp.add(new Token(current.toString()));

			} else {

				/*
				 * If the current character is a open parenthesis: push it onto
				 * the stack.
				 */
				if (current.isOpenParenthesis()) {
					stack.push(new Token(current.toString()));

					/*
					 * If the current character is a close parenthesis: pop from
					 * the stack onto the postfix expression until we reach an
					 * open parenthesis. Pop the open parenthesis, but do not
					 * add it to the postfix expression.
					 */
				} else if (current.isCloseParenthesis()) {
					while (!stack.peek().isOpenParenthesis()) {
						exp.add(new Token(stack.pop().toString()));
					}
					stack.pop(); // pop open-parenthesis

					/*
					 * If the current character is an operator:
					 */
				} else {

					/*
					 * If the stack is empty, push the operator onto the stack.
					 */
					if (stack.isEmpty()) {
						stack.push(new Token(current.toString()));

						/*
						 * If the stack is not empty and the current operator
						 * has lower precedence than the operator on the top of
						 * the stack pop, pop the last element of the stack to
						 * the postfix expression, and push the current
						 * character.
						 */
					} else if (current.isLowPrecedence()
							&& stack.peek().isHighPrecedence()) {
						exp.add(new Token(stack.pop().toString()));
						stack.push(new Token(current.toString()));

						/*
						 * If the stack is not empty and the current operator
						 * has the same precedence as the one on top of the
						 * stack, push the current character onto the stack.
						 */
					} else {
						stack.push(new Token(current.toString()));
					}
				}
			}
		}

		/*
		 * Pop any remaining characters from the stack.
		 */

		while (!stack.isEmpty()) {
			exp.add(new Token(stack.pop().toString()));
		}

		return exp;
	}