-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathJava _Authentication
More file actions
29 lines (24 loc) · 1.07 KB
/
Java _Authentication
File metadata and controls
29 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
his is a Java Program to Illustrate how User Authentication is Done.
Enter username and password as input strings. After that we match both strings against given username and password. If it matches then Authentication is successfull or else Authentication fails.
Here is the source code of the Java Program to Illustrate how User Authentication is Done. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
import java.util.Scanner;
public class User_Authentication
{
public static void main(String args[])
{
String username, password;
Scanner s = new Scanner(System.in);
System.out.print("Enter username:");//username:user
username = s.nextLine();
System.out.print("Enter password:");//password:user
password = s.nextLine();
if(username.equals("user") && password.equals("user"))
{
System.out.println("Authentication Successful");
}
else
{
System.out.println("Authentication Failed");
}
}
}