next()和nextLine()方法的区别
2015-12-04 17:51
363 查看
next()方法是不接收空格的,在接收到有效数据前,所有的空格或者tab键等输入被忽略,若有有效数据,则遇到这些键退出。
nextLine()可以接收空格或者tab键,其输入应该以enter键结束。
下面是API说明:
nextLine()可以接收空格或者tab键,其输入应该以enter键结束。
下面是API说明:
public String 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. |
public String nextLine() | Advances this scanner past the current line and returns the input that was skipped. This method returns the rest of the current line, excluding any line separator at the end. The position is set to the beginning of the next line. Since this method continues to search through the input looking for a line separator, it may buffer all of the input searching for the line to skip if no line separators are present. |
相关文章推荐
- Wamserver 添加虚拟主机的方式
- C++终极复习篇(五)----STL标准模板库
- 黑马程序员——OC学习——@class的使用
- 关于幻读
- 从数据库中获取数据第二个文件结果集
- 7)查找[1]顺序表的查找
- Python中@的用法(Decorator:装饰器)
- 一维byte数组旋转
- Oracle Report : REP-1219
- 从数据库获取数据就以下这两个脚本足够
- 在字符串中删除特定字符
- ThinkPHP框架--关联查询--HAS_MANY--小demo
- Eclipse常用的高效插件
- iOS 新特性分列式 之 iOS 5.x - 主要内容:自动引用计数、故事板、控件自定义呈现、容器视图控制器
- CSS设置字体
- Android常用工具类之 Toast工具类
- UI第十七天:图⽚异步下载、KVO
- MFC 学习之 鼠标移动到Toolbar按钮上显示提示信息(tooltip),状态栏也随之改变
- java字符串切割
- 安装MongoDB