Skip to content

Commit d8fb694

Browse files
committed
Fix
1 parent ce362fe commit d8fb694

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/com/thealgorithms/stacks/PostfixEvaluator.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,24 @@ public static int evaluatePostfix(String expression) {
4141
return stack.pop();
4242
}
4343

44+
/**
45+
* Checks if the given token is an operator.
46+
*
47+
* @param token The token to check.
48+
* @return true if the token is an operator, false otherwise.
49+
*/
4450
private static boolean isOperator(String token) {
4551
return token.equals("+") || token.equals("-") || token.equals("*") || token.equals("/");
4652
}
4753

54+
/**
55+
* Applies the given operator to the two operands.
56+
*
57+
* @param operator The operator to apply.
58+
* @param a The first operand.
59+
* @param b The second operand.
60+
* @return The result of applying the operator to the operands.
61+
*/
4862
private static int applyOperator(String operator, int a, int b) {
4963
return switch (operator) {
5064
case "+" -> a + b;

0 commit comments

Comments
 (0)