import javax.swing.*;
public class A {
public static void main (String args[]){
String ask = JOptionPane.showInputDialog("Enter");
if(ask.equals("hello")){
System.out.println("ok.");
main(args);
}else if(isRepeat(ask)){
System.out.println("Invalid,string has been repeated.");
System.exit(0);
}
}
public static boolean isRepeat(String ask){
if(ask.equals("hello")){
return true;
}else{
return false;
}
}
}
Hello, I am having problems with my code. IF i input again the "hello", it still prints out "ok". How can I terminate the program, if i input again "hello"?.Please help me. Thank you for the help in advance.