当前位置:网站首页>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、可以获得空白。
边栏推荐
猜你喜欢

Stop saying that you can't solve the "cross domain" problem

Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS

Huawei operator level router configuration example | BGP VPLS and LDP VPLS interworking example

C语言多线程编程入门学习笔记

实战 ELK 优雅管理服务器日志

CX5120控制汇川IS620N伺服报错E15解决方案

HTB-Lame

Introduction and basic knowledge of machine learning

Huawei operator level router configuration example | configuration static VPLS example

POI导出excel,按照父子节点进行分级显示
随机推荐
A few lines of transaction codes cost me 160000 yuan
别再说不会解决 “跨域“ 问题啦
Leetcode 1818 absolute value, sorting, dichotomy, maximum value
The best learning method in the world: Feynman learning method
MySQL index --01--- design principle of index
Data exchange JSON
Ridge regression and lasso regression
An article explaining the publisher subscriber model and the observer model
JS daily development tips (continuous update)
Clion and C language
VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license
多元线性回归
So easy 将程序部署到服务器
Depth first traversal of C implementation Diagram -- non recursive code
雪崩问题以及sentinel的使用
MySQL knowledge points
STM32 - DS18B20 temperature sampling of first-line protocol
【EXSI】主机间传输文件
文件上传下载
Chapitre 03 Bar _ Gestion des utilisateurs et des droits