Skip to content

Instantly share code, notes, and snippets.

@canokay
Created November 15, 2018 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canokay/a4d5bb80c4f4b0bb32fa6f7d866be68e to your computer and use it in GitHub Desktop.
Save canokay/a4d5bb80c4f4b0bb32fa6f7d866be68e to your computer and use it in GitHub Desktop.
Java Console Login Example
import java.util.Scanner;
public class JavaConsoleLogin {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Kullanıcı Adı: ");
String username= input.nextLine();
System.out.print("Şifre: ");
String password= input.nextLine();
System.out.println("Kullanıcı adı: " + username);
System.out.println("Şifre: " + password);
if (username.equals(username)){
if (password.equals("asd123")){
System.out.println("Doğru giriş yaptı...");
}
else{
System.out.println("Şifre yanlış :(");
}
}
}
}
@Javascriper
Copy link

I'm new to java and whenever I type this Scanner input = new Scanner(System.in); I got this warning saying "Resource linked: input is never closed"... Though the code runs fine without any error, but Eclipse keeps indicating this warning and I don't like leaving warnings on my code especially when I don't know what they mean.

@ngongiotieudao
Copy link

input.close(); to end function main

@MominVakas
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment