---
title: "Discussion on \"Java: incompatible types: String cannot be converted to int, and how to fix it\" | Hashnode"
description: "Discussion on \"Java: incompatible types: String cannot be converted to int, and how to fix it\". nextLine() always gives you text. Here's why Java won't put it into an int, and the fix with Integer.parseInt."
url: "https://hashnode.com/posts/java-incompatible-types-string-cannot-be-converted-to-int/6aeda83c9f0090e5f961c4bf"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Java: incompatible types: String cannot be converted to int, and how to fix it](https://craftstack.hashnode.dev/java-incompatible-types-string-cannot-be-converted-to-int?utm_source=hashnode&utm_medium=feed)

nextLine() always gives you text. Here's why Java won't put it into an int, and the fix with Integer.parseInt.

Nov 6 · 9 min read · craftstack.hashnode.dev  
Read the article

-   [#java](https://hashnode.com/tag/java)
-   [#debugging](https://hashnode.com/tag/debugging)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#learn-coding](https://hashnode.com/tag/learn-coding)

## Written by

[Craftstack Academy](https://hashnode.com/@cstackacademy)

@cstackacademy

  
[View profile](https://hashnode.com/@cstackacademy)

AI coding tutor for beginners: Python, Web, SQL, Java. Free trial: craftstackacademy.com/trial

One-hour coding sessions with an AI tutor. You write every line. Free 20-minute trial, no card.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
