Create a Java program to demonstrate the use of an interface for custom authentication
interface Authenticator { boolean authenticate(String username, String password); } public class Main { public static void main(String[] args) { Authenticator authenticator = (username, password) -> { // Simulate authentication logic return username.equals("Admin") && password.equals("Admin123"); }; String username = "Admin"; String password = "Admin123"; boolean isAuthenticated = authenticator.authenticate(username, password); System.out.println("Is User Authenticated? " + isAuthenticated); } }
Is User Authenticated? true
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions