CheatSheets-for-Developers
CheatSheets-for-Developers copied to clipboard
Fixing null pointer exception on the nextLine()
Change Summary
NullPointerException caused by attempting to invoke the method hasMoreTokens() on a StringTokenizer object (st) that is null. This happens in the nextLine() method of your FastReader class.
Ensuring that st is properly initialized before calling hasMoreTokens() in the nextLine() method by modifying the nextLine() method to initialize st if it is null:
Checklist
If you haven't fulfilled the below requirements or even delete the entire checklist, your PR won't be reviewed and will be closed without notice.
General
- [x] This Pull Request is all my own work. (You'll be blacklisted if you are caught for plagiarism.)
- [x] I've read CONTRIBUTING.md
- [x] I've made some valid changes to the CheatSheet, and they are not just minor changes.
Changes
- [x] I've read and followed the Solution Template
Note: To mark the checkbox, put an x inside the [ ] (like this: [x]).