Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing null pointer exception on the nextLine() #241

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edd-ie
Copy link

@edd-ie edd-ie commented Nov 7, 2024

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

  • This Pull Request is all my own work. (You'll be blacklisted if you are caught for plagiarism.)
  • I've read CONTRIBUTING.md
  • 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]).

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.

# Fix
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:
Copy link

netlify bot commented Nov 7, 2024

Deploy Preview for cheatsheets failed.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant