+ 2
is there a way to see a part of a Scanner object without consuming it?
so I have a Scanner object and I read into it an equation say 3 * 5 ^ 7 so I am using two stacks and I need to see if the next operator has higher precedence without removing it from the Scanner object because that would break my method. so I need a way to either make a copy of the Scanner to pass to another method for a precedence check without it just creating a reference to the original Scanner or I need to be able to see the next operator to use for comparison without consuming it using the next() method.
2 ответов
+ 4
Kit D. Cat yeah i know its not the most elegant solution but it works for now, i will definitely take a look at your code and see about implementing it! i appreciate the help!
+ 3
Kit D. Cat i figured out a way to do it by creating a second scanner and placing all of the remaining characters into a string then re-initializing my original scanner and a copy with the same values, i will however check out the aforementioned class and see if i can utilize it somehow!