how to convert the entire string to java if the string is similar to String str = & ldquo; 1234 & quot;

advertisements

how to convert the string to integer in java if the string is like this:

String str="  1234";

note there is space in the beginning of the string. i tried Integer.parseTnt(str) method. But java shows NumberFormatException. Help me how to do?


Try this one Integer.parseInt(str.trim());