-
If you chain 3 of these, it'll work. And read the links chris provided.
Code:
GET
USER
INPUT <--------------------
. |
| |
| |
+-------------------+ ,,
| | ,'` `.
| while(condition) | / \
| |-------->| RETRY |
| M OR F ? | false \ /
| | '. ,'
| | ```
+--------/----------+
|
|
|
|
| true
----
NEXT
----
-
I have change it to this
if((age<=0) && (!g.matches("^[mMfF]$"))){
System.out.println("Age and gender both are incorrect");
System.out.println("need to enter all details again");
continue;
}else if(age<=0){
System.out.println("age is less than or equal to 0");
System.out.println("need to enter all details again");
continue;
} else if(!g.matches("^[mMfF]$")){
System.out.println("Gender must be male or female other characters found");
System.out.println("need to enter all details again");
continue;
}
problem resolved thanks everyone thank you very much.
:)