Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

for loop condition java

import java.util.Scanner;

public class Sample {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String usernames[] = { "jasmine", "Lyka", "marbie" };
        String password[] = { "jasmine123", "lyka123", "marbie123" };
        System.out.print("Enter Username: ");
        String user = input.nextLine();
        System.out.print("Enter Password: ");
        String pass = input.nextLine();
        boolean isExist = false;
        for (int i = 0; i < password.length; i++) {
            if (user.equals(usernames[i]) && pass.equals(password[i])) {
                isExist = true;
                break;
            }

            if (isExist = true) {
                System.out.println("Welcome! " + user);
            } else {
                System.out.println("Account not Found!");
            }
        }

        input.close();
    }
}
Source by api.mercadolibre.com #
 
PREVIOUS NEXT
Tagged: #loop #condition #java
ADD COMMENT
Topic
Name
6+9 =