NumberFormatException in Java — What It Means and How to Fix It

What Java's NumberFormatException means and how to fix it.

Published November 2, 2026

NumberFormatException is thrown when code tries to convert a string into a number, but the string isn't a valid numeric format.

Key points

  • Read the full stack trace from the top — it names the exact class, method, and line where the exception originated

Example

Integer.parseInt("abc");  // NumberFormatException
More Java articles