import java.util.Scanner;
public class Exercise1 {
public static void main(String[] args){
System.out.println("请输入用户名:");
Scanner input=new Scanner(System.in);
String name=input.next();
System.out.println("请输入密码:");
int secret=input.nextInt();
if(name.equals("青")&&(secret=123)){
System.out.println("欢迎你,青");
}else {
System.out.println("对不起,你不是青");
}
}
}
判断是否相等,用“==”,“=”是赋值
import java.util.*;
public class A {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("请输入用户名:");
Scanner input=new Scanner(System.in);
String name=input.next();
System.out.println("请输入密码:");
int secret=input.nextInt();
String str1="青";
int sec=123;
if((name.equals(str1)) && (secret==sec)){
System.out.println("欢迎你,青");
}else {
System.out.println("对不起,你不是青");
}
}
}