Error:Java Scanner nextLine not working after next[Solution]

Published: 11 January 2021
on channel: BS Sandhu
3,990
59

In Scanner class if we call nextLine() method after any one of the seven nextXXX() method then the nextLine() doesn’t not read values from console and cursor will not come into console it will skip that step.
The nextXXX() methods are nextInt(), nextFloat(), nextByte(), nextShort(), nextDouble(), nextLong(), next().

This problem occurs only for Scanner class, due to nextXXX() methods ignore newline character and nextLine() only reads till first newline character. If we use one more call of nextLine() method between nextXXX() and nextLine(), then this problem will not occur because nextLine() will consume the newline character

#Java #Scanner #Error
I hope you enjoyed java tutorial!

Previous Video :   • How to Take input from User in Java using ...  
--- Thank you for your love and support ---
Thanks NCS for wonderful work:
Track: Besomorph - Afterlife (ft.EMM) [NCS Release]
Music provided by NoCopyrightSounds.
Watch:    • Besomorph x EMM - Afterlife | Electronic |...  
Free Download / Stream: http://ncs.io/Afterlife


On this page of the site you can watch the video online Error:Java Scanner nextLine not working after next[Solution] with a duration of hours minute second in good quality, which was uploaded by the user BS Sandhu 11 January 2021, share the link with friends and acquaintances, this video has already been watched 3,990 times on youtube and it was liked by 59 viewers. Enjoy your viewing!