samedi 1 octobre 2016

My "if" statement is not readable [duplicate]

This question already has an answer here:

Here's my code, have a look at it. I'm new to java so I'm just trying to make small programs.

import java.util.Scanner;
import java.util.Random;
public class gayrandom 
{

    private static Scanner scan;

    public static void main(String[] args)
    {       
        Scanner keyboardIn = new Scanner(System.in);


        System.out.println("Please enter your name : ");
        String name= keyboardIn.next(); 
            if   (name=="Eugen")

            {
                System.out.println("Bruh, he's not gay.");
            }
            else 
            {

                Random rand = new Random(); 
        int value = rand.nextInt(101); 

        System.out.println("Hello " +name +", you are " +value +"% gay. Congrats!");
            }

    }
}

Any ideas why it's not following the if statement? It's going straight to the end of the code to display the answer but it's skipping the name / not reading the name.

Aucun commentaire:

Enregistrer un commentaire