Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的这部分代码似乎不起作用。我觉得问题可能与代码的 stk.peek() 部分有关,但我不确定这是否属实。有任何想法吗?
stk 是我的堆栈,读入代码的第一件事是“(”
if(stk.empty()==true || stk.peek()== "("){ stk.push(post.get(i)) System.out.println("Test1:" +stk.peek()); }
试试这个。这应该可以做到,并且有更好的风格。
if (stk.empty() || "(".equals(stk.peek())){ stk.push(post.get(i)); System.out.println("Test1:" + stk.peek()); }