How to parse an int from a string in java?

Sometimes, you need to convert a string that represents a number into an actual integer.

Example:


  String numberStr = "123";
  int number = Integer.parseInt(numberStr);
  System.out.println(number + 1);  // Outputs: 124
  

Beginner's Guide to Java