当前位置:网站首页>10、Scanner. Next() cannot read spaces /indexof -1
10、Scanner. Next() cannot read spaces /indexof -1
2022-07-01 03:35:00 【weixin_ forty-seven million one hundred and twenty-seven thousa】
Cause :
1. Use Scanner.next Get keyboard input name
2.name.indexOf by -1
answer :
next()
1、 Be sure to read valid characters before entering .
2、 Blank space before entering valid characters ,next() Method will automatically remove it .
3、 Only after entering a valid character, the space after it is used as a separator or terminator .
4、next() Cannot get string with space .
nextLine()
1、 With Enter End of character ,nextLine() Method returns all characters before entering carriage return .
2、 Can get blank .
边栏推荐
猜你喜欢
随机推荐
Overview of EtherCAT principle
Hello World generation
Feature Pyramid Networks for Object Detection论文理解
A few lines of transaction codes cost me 160000 yuan
Force buckle - sum of two numbers
FCN全卷積網絡理解及代碼實現(來自pytorch官方實現)
pytest-fixture
Edge drawing: a combined real-time edge and segment detector
Edge Drawing: A combined real-time edge and segment detector 翻译
Promise中finally的用法
[reading notes] copywriting realization -- four golden steps for writing effective copywriting
Split(), split(), slice(), can't you tell?
Md5sum operation
Gorilla/mux framework (RK boot): RPC error code design
复习专栏之---消息队列
GCC usage, makefile summary
JS日常开发小技巧(持续更新)
Thread data sharing and security -threadlocal
Hal library operation STM32 serial port
Filter









