next();方法会阻塞,到这个方法的时候,就停下来等你输入。
JDK官方说明:
next();
Finds and returns the next complete token from this scanner. A complete token is preceded and followed by input that matches the delimiter pattern. This method may block while waiting for input to scan, even if a previous invocation of hasNext() returned true.
以我的理解,在Scanner sc=new 的时候是对对象sc的实例化,当调用next()时,此时应该是等待输入。。。