1、不存在Char,除非你自己定义一个类。char才是java基本类型之一
2、a.next()返回的是一个String类型,也不可能用char来接收
3、if语句中,判断相等用的是==而不是一个=
import java.util.*; import *; public class H7323 { /** * @param args */ public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.println("请输入用户名:"); String name = a.next(); Scanner b= new Scanner(System.in); System.out.println("请输入密码:"); int pin = b.nextInt(); if (name=="青"&&pin==123){ System.out.print("欢迎你,青!"); }else{ System.out.print("对不起,你不是青!"); } } // TODO Auto-generated method stub }
public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.println("请输入用户名:"); String name = a.next(); Scanner b = new Scanner(System.in); System.out.println("请输入密码:"); int pin = b.nextInt(); if ( "青".equals(name) && pin == 123) { System.out.print("欢迎你,青!"); } else { System.out.print("对不起,你不是青!"); } }
import java.util.Scanner; public class H7323 { public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.println("请输入用户名:"); String name = a.next(); Scanner b = new Scanner(System.in); System.out.println("请输入密码:"); int pin = b.nextInt(); if ( "青".equals(name) && pin == 123) { System.out.print("欢迎你,青!"); } else { System.out.print("对不起,你不是青!"); } } }怎么这样呀?输入密码的时候就和死机似的,我输出的123,半天就出来个12.而且按回车也不往下进行呀?
import java.util.Scanner; public class H7323 { public static void main(String[] args) { Scanner a = new Scanner(System.in); System.out.println("请输入用户名:"); String name = a.next(); Scanner b = new Scanner(System.in); System.out.println("请输入密码:"); int pin = b.nextInt(); if ( "青".equals(name) && pin == 123) { System.out.print("欢迎你,青!"); } else { System.out.print("对不起,你不是青!"); } } }哪位大神知道咋回事不?