当前位置:网站首页>10、Scanner.next() 无法读取空格/indexOf -1
10、Scanner.next() 无法读取空格/indexOf -1
2022-07-01 03:13:00 【weixin_47127217】
原由:
1.使用Scanner.next获取键盘输入 name
2.name.indexOf 为-1
解答:
next()
1、一定要读取到有效字符后才可以输入。
2、对输入有效字符之前的空白,next()方法会自动将它去掉。
3、只有输入有效字符后才将其后面的空白作为分隔符或结束符。
4、next()不能得到带有空格的字符串。
nextLine()
1、以Enter为结束符,nextLine()方法返回的是输入回车之前的所以字符。
2、可以获得空白。
边栏推荐
- Huawei operator level router configuration example | BGP VPLS configuration example
- 别再说不会解决 “跨域“ 问题啦
- MySQL knowledge points
- shell脚本使用两个横杠接收外部参数
- 咱就是说 随便整几千个表情包为我所用一下
- Force buckle - sum of two numbers
- Data exchange JSON
- About the application of MySQL
- 岭回归和lasso回归
- How do spark tasks of 10W workers run? (Distributed Computing)
猜你喜欢

文件上传下载

Ctfshow blasting WP

Ridge regression and lasso regression

Introduction to EtherCAT

Analyze datahub, a new generation metadata platform of 4.7K star

JUC学习

Depth first traversal of C implementation Diagram -- non recursive code

最好用的信任关系自动化脚本(shell)

Chapter 03_ User and authority management

Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS
随机推荐
How do spark tasks of 10W workers run? (Distributed Computing)
Latest interface automation interview questions
Const and the secret of pointers
Completely solve the lost connection to MySQL server at 'reading initial communication packet
Force buckle - sum of two numbers
JUC learning
别再说不会解决 “跨域“ 问题啦
[applet project development -- Jingdong Mall] classified navigation area of uni app
数组的includes( )
HTB-Lame
Basic concept and classification of sorting
JS日常开发小技巧(持续更新)
So easy 将程序部署到服务器
岭回归和lasso回归
Golang多图生成gif
leetcode 1482 猜猜看啊,这道题目怎么二分?
Metadata in NFT
HTB-Lame
Keil5中如何做到 0 Error(s), 0 Warning(s).
最新接口自动化面试题