我需要返回上一行代码--Java

时间:2014-05-27 22:53:12

标签: java function methods return line

我正在编写一个让这个人输入性别的代码:

public static void main(String args[]) {
    System.out.println("Welcome to our dating website!");
    System.out.println("Please enter your gender:");
    Scanner Gender = new Scanner(System.in);
    String GenderInput = Gender.nextLine(); 
    //INPUT - This is holding the String under GenderInput, Named Gender
    if (GenderInput.equalsIgnoreCase("Male")){
        System.out.println("Sir, please enter your age:");
    }
    else if (GenderInput.equalsIgnoreCase("Female")){
        System.out.println("Ma'am, please enter your age:");
    }
    else {
        System.out.println("That is not a gender.");

    }

我想知道的是,如果这个人没有进入男性或女性,我会把它放在其他地方,那么它会回来要求输入他们的性别吗?

0 个答案:

没有答案