loop label code example

Example 1: label in loop

label in loop

Example 2: for label loop

void enterEmail()
        {
            String Email=null;
            String Choose=null;
            String newName=null;
            String newEmail=null;
            String line="";
            
            System.out.print("Please Enter your email:");
            Email=keyboard.nextLine();
                label1:
           for(int i=0; i<eshop.buyersList.size(); i++)
           {
                 if(eshop.buyersList.get(i).getEmail().equals(Email))
                {
                    //Buyer buyer1=new Buyer(buyer.getName(),Email);
                System.out.println("You logged in !!!");
                System.out.println("Welcome "+eshop.buyersList.get(i).getName()+".Your personal details are: ");
                eshop.buyersList.get(i).getBuyerInfo();
                break;
             }
             
            // else if(eshop.buyersList!=null)
            // {  
                // continue label1;
                //}
             
            else
           {
               
            System.out.println("You do not own an account in our E-shop.\n Do you wish to create a new one ?\t(Type Yes or No)");
            Choose=keyboard.nextLine();
            
            while(!(Choose.equals("Yes") || Choose.equals("No")))
           {
               System.out.println("Please Type in Yes or No. Anything else it's incorrect!!!");
               Choose=keyboard.nextLine();
                }
                
            if(Choose.equals("Yes"))
            {
                System.out.println("Please enter your name:");
                newName=keyboard.nextLine();
                System.out.println("Please enter a new email:");
                newEmail=keyboard.nextLine();
                while(eshop.buyersList.contains(buyer.getEmail()))
                {
                    System.out.println("This email is already in use.\n Please enter a new one. ");
                    newEmail=keyboard.nextLine();
                }
                Buyer buyer1=new Buyer(newName,newEmail);
                eshop.addBuyer(buyer1);
                break;
            }
            
               else if(Choose.equals("No")){System.out.println("\nThank you for visiting our E-Shop! =D");  System.exit(0);}
          }
        }
    }