一直找不到什么問題,求解答


代碼附上
public static void main(String[] args) {
System.out.println("請先輸入用戶名:");
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
if(i == 123){
System.out.println("請輸入密碼");
int j = sc.nextInt();
if(j==456){
System.out.println("登錄成功");
}else{
System.out.println("登錄失敗");
}
}else{
System.out.println("用戶名錯誤");
}
sc.close();
}
public static void main(String[] args) {
System.out.println("請先輸入用戶名:");
Scanner sc = new Scanner(System.in);
String i = sc.nextInt();
if(i == 123){
System.out.println("請輸入密碼");
String j = sc.nextInt();
if(j==456){
System.out.println("登錄成功");
}else{
System.out.println("登錄失敗");
}
}else{
System.out.println("用戶名錯誤");
}
sc.close();
}
uj5u.com熱心網友回復:
java里面String只能用equals方法判斷內容。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/284276.html
標籤:Java SE
上一篇:服務器部署SSL后網頁跳轉404
