したがって、ユーザーが 453-* のような後置値を入力した場合、私のメソッド EvalPostFix() は機能しますが、ユーザーが 43*+ のような無効なものを入力したり、無効な文字列を入力したりすると、プログラムはユーザーに入力を再要求します。 try catch で実装する方法..
'
String in;
while(true){
System.out.println("Please enter the numbers first followed by the operators, make sure to have one less operator than of numbers");
try {
in = getString();
int result = EvalPostFix(in);
System.out.println(result);
} catch (IOException e) {
// TODO Auto-generated catch block
String s = "Not a valid postfix string";
e.toString();
in = getString();
}
}
'