---
title: "Comment by Wellington Domiciano on \"Java: String after Integer causing error?\" | Hashnode"
description: "Nice! This is a good way to overcome this situation. Another approach would be to pass nextLine() to parseInt() : int year = Integer.parseInt(in.nextLine()); I"
url: "https://hashnode.com/posts/java-string-after-integer-causing-error/6207cfadd59187113c4c09ba/comment/62083af0a2be760e35396c3c"
---

[Discussion](https://hashnode.com/posts/java-string-after-integer-causing-error/6207cfadd59187113c4c09ba)

Comment [Java: String after Integer causing error?](https://hashnode.com/posts/java-string-after-integer-causing-error/6207cfadd59187113c4c09ba)

[Wellington Domiciano](https://hashnode.com/@wldomiciano)

[Feb 12, 2022](https://hashnode.com/posts/java-string-after-integer-causing-error/6207cfadd59187113c4c09ba/comment/62083af0a2be760e35396c3c)

Nice! This is a good way to overcome this situation.

Another approach would be to pass `nextLine()` to `parseInt()`:

```
int year = Integer.parseInt(in.nextLine());
```

I like it better this way because for me it's less confusing than having a `nextLine()` lost between the lines.
