为什么我的while循环中断

-1 java loops break while-loop

我无法弄清楚为什么我的while循环不会破坏它只是继续运行我尝试制作Lc 10并且我尝试返回但是没有任何东西会结束循环.

import java.util.Scanner;
public class BirthdayReminder
{

   public static void main (String[] args)
   {
      Scanner input = new Scanner(System.in);
      String[] BDay = new String[10];
      String[] friend = new String[10];
      int Lc = 0;
      String i;

      while(Lc < 10) {
            System.out.println("enter a friends name or zzz to quit");
            i = input.nextLine();
            if(i == "zzz") { 
                break;
            }
            else if(i != "zzz"){
            friend[Lc] = i;
            System.out.println("enter their birthday.");
            i = input.nextLine();
            BDay[Lc] = i;
            Lc++;
            return;
            }
      }
      System.out.println("hi");

   }
Run Code Online (Sandbox Code Playgroud)

}

Vee*_*Arr 5

您需要使用equals()而不是检查字符串相等性==.if进入内部的代码块都没有输入,因此Lc永远不会增加.