猿问

运行时卡主,什么问题?

public class Test {
 
    public static void main(String[] args) {
         
        Scanner sc=new Scanner(System.in);
        sc.next();
        String x=sc.next();
         //想将用户名x改成手动输入,一运行就卡主,不知道哪里出了问题?去掉Scanner方法,直接给x赋值则运行正常
        User u = new User(x, "123456");
        User u1 = new User("Mike", "123456");
        u.yhxx();
        u1.yhxx();
        System.out.println("===========================");
        UserManager um = new UserManager();
        um.checkUser(u, u1);
     
    }
 
}
     
    public class User {
 
    private String user;
    private String password;
 
    public void yhxx() {
        System.out.println("用户名:" + getUser());
        System.out.println("密码:" + getPassword());
    }
 
    public User(String user, String password) {
        this.user = user;
        this.password = password;
    }
 
    public String getUser() {
        return user;
    }
 
    public void setUser(String user) {
        this.user = user;
    }
 
    public String getPassword() {
        return password;
    }
 
    public void setPassword(String password) {
        this.password = password;
    }
 
}
public class UserManager {
    public String checkUser(User u, User u1) {
        if (u.getUser() != null && u1.getPassword() != null) {
            if (u.getUser().equals(u1.getUser())) {
                System.out.println("用户名一致");
            } else {
                System.out.println("用户名不一致");
            }
        } else {
            System.out.println("用户名输入为空");
        }
 
        return null;
 
    }
 
}

public class Test {

   public static void main(String[] args) {
       
       Scanner sc=new Scanner(System.in);
       sc.next();
       String x=sc.next();
       //想将用户名x改成手动输入,一运行就卡主,不知道哪里出了问题?去掉Scanner方法,直接给x赋值则运行正常
       User u = new User(x, "123456");
       User u1 = new User("Mike", "123456");
       u.yhxx();
       u1.yhxx();
       System.out.println("===========================");
       UserManager um = new UserManager();
       um.checkUser(u, u1);
   
   }

}

白日梦想家XJQ
浏览 1606回答 0
0回答

慕瓜9220888

FKTIHSXBSDEDQPZABBQBUQGDAHFZTZPSYFQGOWJIEOLVJQBTZPZGRLNATZGRBPAZDZCCSJHOLQJPVPQKRSNTIEYMGQVNCMBPJTKMKXRNOSSKSFKGZWNRIGRAQWJHHHEZFMPQAXYLGZFRHYMMVQMBESSTDJOQWCZJDKBGMRIQIJJRPSPLPQPSQRAGFMTIJPENTISTGXFW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QRYNQSVGANHRCSPCULSCBCEHNHHNEJXDTCZJURWRWCWEBVCKFUKQABYNWBDQMQXIFESVOYGXBRGVLCYWBMUSGMVMNHOSCDMSBFQFSOIIKQCWDKQPFEALVZZTEUTZGWNSAFYXNRJKOZEUTFGNNGACINQRRTDARUGZJHBVAOXGTUWHKBGJMGLUBPUSPONIKBFSNGUDAELINIAWCNUYSIJIYEYPTTTUKZZWEBFUPLHQRRBJQBNQTABFPFREADXOEIQNWPIFMHRLWLDJDTELDFUSZITQFQVHTJWKQATVHQJKEIFFAQVFZPNEHCRNJNUZNKJMLYVSZDCEDJYZGGGWBAGPQEVCUPVAJDHBL

waste_time

那是在等待你输入值,你输入按回车就接着运行了
随时随地看视频慕课网APP

相关分类

Java
我要回答