File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
src/main/java/com/thealgorithms/others Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 1
1
package com .thealgorithms .others ;
2
2
3
- import java .util .*;
3
+ import java .util .Scanner ;
4
+ import java .util .Stack ;
4
5
5
- public class StackPostfixNotation {
6
-
7
- public static void main (String [] args ) {
8
- Scanner scanner = new Scanner (System .in );
9
- String post = scanner .nextLine (); // Takes input with spaces in between eg. "1 21 +"
10
- System .out .println (postfixEvaluate (post ));
11
- scanner .close ();
6
+ public final class StackPostfixNotation {
7
+ private StackPostfixNotation () {
12
8
}
13
9
14
10
// Evaluates the given postfix expression string and returns the result.
15
- public static int postfixEvaluate (String exp ) {
11
+ public static int postfixEvaluate (final String exp ) {
16
12
Stack <Integer > s = new Stack <Integer >();
17
13
Scanner tokens = new Scanner (exp );
18
14
You can’t perform that action at this time.
0 commit comments