为什么不进入While循环?

时间:2016-03-15 18:27:51

标签: java random while-loop

抱歉这种语言。我只是无法理解为什么它不会进入第一个while循环并直接到最后。 while以布尔值开头,但它不会继续。 我可以用一些帮助:) 提前致谢。 现在它的(一半)满了。 它与等于字符串没有任何关系。 再次感谢。

package guessTheNumber;

import java.util.Random;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        //Opening of the scanner.
        Scanner guess = new Scanner (System.in);

        //Entry - what the player will see before he starts.
        System.out.println("Hello.");
        System.out.println("Wellcome to the Guess the number game");
        String enter = guess.nextLine();
        System.out.println("I choose a nember and you have to guess what it is.");
        enter = guess.nextLine();
        System.out.println("Ready?");
        System.out.println("I don't care... Type NEW to start");

        String startGame = guess.nextLine(); 
        while (startGame == "NEW" || startGame == "New" || startGame == "new"){

            //generates new number
            Random newNumber = new Random();
            int newRandom = newNumber.nextInt();
            //here the player can guess the number
            System.out.println("I chose a number between 1-bitch. what number am I thinking of? ");


        //if the player chooses to end the game
        System.out.println("See you later mother ******.");

    }

}

0 个答案:

没有答案