使用到了ArrayDeque集合:使用ArrayDeque表示Queue比LinkedList、表示Stack效率更高
ArrayDeque使用详解
package com.kiger.Demo;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.Stack;
/**
* @ClassName SuffixExpression
* @Description TODO
* @Author zk_kiger
* @Date 2019/9/26 11:32
* @Version 1.0
*/
public class SuffixExpressionUtil {
private SuffixExpressionUtil() {
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char s[] = input.nextLine().toCharArray();
ArrayDeque<String> suffix = SuffixExpressionUtil.TransformSuffix(s);
Integer result = SuffixExpressionUtil.SuffixCalculate(suffix);
System.out.println(result);
}
// 将中缀表达式转化为后缀表达式
public static ArrayDeque<String> TransformSuffix(char[] s) {
ArrayDeque<String> queue = new ArrayDeque<>();
Stack<Character&