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...

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.

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

String s = null;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.