Can someone explain to me why when I try to use the variable custemp,emptemp,admdtemp after the if statement I get null and how to fix it?
case 2:// login a user but do some input validation
            System.out.println("Enter login Username: ");
            username =s.nextLine();
            
            if (userDao.findByUsername(username).getRole().equals("Customer")){
            custemp=userDao.findByUsername(username);
            
            }else if
(userDao.findByUsername(username).getRole().equals("Employee")){
                emptemp=userDao.findByUsername(username);
                
            }else if (userDao.findByUsername(username).getRole().equals("Admin")){
                    admtemp=userDao.findByUsername(username);
                    
                }
        
            //System.out.println(custemp);
            boolean k= aService.usernameAuthentication(username);
            if(k==false) {
                do {
                System.out.println("Username does not exist enter in a valid username");
                System.out.println("Enter username: ");
                username=s.nextLine();
                k=aService.usernameAuthentication(username);
                
               
                }while(!k);
            }
            System.out.println("Enter login Password: ");
            password=s.nextLine();
            boolean m= aService.passwordAuthentication(username,password);
            if(m==false) {
                do {
                System.out.println("Password is not associated with user");
                System.out.println("Enter password: ");
                password=s.nextLine();
                m=aService.passwordAuthentication(username,password);
                
               
                }while(!m);
            }
            
            boolean c=userService.login(username, password);
            while(c) {
                
                if(custemp.getRole().toString()=="Customer") {
                    
                    while(!gobackmainMenu) {
                    printMenuCusAccM();
                    int choice2= getInputCusAccM();
                    operonCusAcc(choice2);
                    }
                }
                if(emptemp.getRole().toString()=="Employee") {
                    printMenuEmpAccM();
                    while(!gobackmainMenu) {
                    int choice3= getInputEmpAccM();
                    operonEmpAcc(choice3);
                    
                    }
                }
                if(admtemp.getRole().toString()=="Admin") {
                    printMenuAdmAccM();
                    while(!gobackmainMenu) {
                    int choice4= getInputAdmAccM();
                    
                    }
                }
            }
            
            break;
 
    