0
public class Calculator {

      public static void main(String[] args)  {
          String s;  // string that holds the expression

            s = JOptionPane.showInputDialog("Enter a simple infix expression: ");
}
}

    public static String infixToPrefix(String result){
            JOptionPane.showMessageDialog(null,"Invalid character in expression: " + c);
}

hello guyz,,actually this is not my whole code,,i just shorten it because it's too long..i just want to ask if how to return to main method..If i input an invalid character,,it will automatically read the "infixToPrefix" method...how will i return to "main" if i want to "enter a simple infix expression" again???.......i hope you can help me guyz...

Edited by mike_2000_17: Fixed formatting

2
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by masijade
0

Loop until you have a valid value.

i.e.

String s;
while ((s==null) || s.equals("")) {
    s = JOptionPane.showInputDialog("Enter a simple infix expression: ");
}

Although you will have to define the parameters, that is just an example.

0

i already done it,,but it the String s will not be read...it may not have initialized according to...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.