Java input not recognizing string
<p>For the following code, if I type y on the keyboard, it enters the else portion of the branch statement. Why is that?</p>

<pre><code>    public static void getInput(){
   String response; 
    String[] coins = new String[6]; 

    System.out.println("Would you like to enter your own amount? (y/n)");  

    Scanner sc = new Scanner(System.in);
    response=sc.nextLine();

    if (response=="y"){
       System.out.println("You entered y");
        }
   else{
       System.out.println("You did not enter y, you entered " + response);
        }
    }
</code></pre>
