userimage

How to convert numeric String to int or Integer using Java code

I have a string as below:

String num = "24";

what is the best way to convert this string to integer?

userimage

Try as below and you will get your expected result:


int i = Integer.parseInt(num);

Answer is