CheatSheets-for-Developers icon indicating copy to clipboard operation
CheatSheets-for-Developers copied to clipboard

Fixing null pointer exception on the nextLine()

Open edd-ie opened this issue 1 year ago • 1 comments

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

Note: To mark the checkbox, put an x inside the [ ] (like this: [x]).

edd-ie avatar Nov 07 '24 22:11 edd-ie

Deploy Preview for cheatsheets failed.

Name Link
Latest commit e2a5eebf599524217906955c074b221183a6f1ff
Latest deploy log https://app.netlify.com/sites/cheatsheets/deploys/672d466130c564000816406d

netlify[bot] avatar Nov 07 '24 23:11 netlify[bot]