Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //login class
- /**
- * Created by yst on 11/03/2016.
- */
- public class login {
- private String username;
- private String password;
- //default constructor
- public login(){
- username=" ";
- password=" ";
- }
- //normal constructor
- public login(String u,String p){
- username=u;
- password=p;
- }
- //getter
- public String getUsername(){
- return username;
- }
- public String getPassword(){
- return password;
- }
- }
- //main class
- /**
- * Created by yst on 11/03/2016.
- */
- import java.util.*;
- public class APP {
- public static void main(String[] args){
- String username=" ",password=" ";
- Scanner input=new Scanner(System.in);
- System.out.print("USERNAME :" );
- username=input.next();
- System.out.print("PASSWORD :");
- password=input.next();
- //Arraylist for login
- ArrayList<login> a =new ArrayList<login>();
- //adding object to a arraylist
- a.add(new login("balqis","hanis"));
- a.add(new login("safuan","alane"));
- a.add(new login("abah","caah"));
- //username and password will be search according to the index respectively
- for(int counter=0;counter<a.size();counter++){
- if((a.get(counter).getUsername().equalsIgnoreCase(username))&&(a.get(counter).getPassword().equalsIgnoreCase(password))) {
- System.out.println("Sucessfully Login");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement