Here is my code:
String test = "12+23-42-53+4-31";
int counter = 0;
Stack<Integer> numb= new Stack<Integer>();
Stack<String> op = new Stack<String>();
for(int i = 0; i<test.length();i++){
if(test.charAt(i)=='-' || test.charAt(i)=='+'){
int number = Integer.parseInt(test.substring(counter, i));
counter=i+1;
numb.push(number);
String oper = Character.toString(test.charAt(i));
op.push(oper);
}
}
If I loop through numb stack then the last number of test string is missing. Are there any solutions?