to read, 1.6K views since 2016.12.16

Convert string to integer in java

When you got a value from a user for example in a form of a string but it contains numerical value you can use Integer.parseInt() method to convert a String to int:

String productPrice = "499";
int parsedPrice = Integer.parseInt(productPrice);
System.out.println(parsedPrice);

will output in the follow :

499