Example for converting numeric string to int in java -
public class StringToIntExample
{ public static void main (String[] args) { String s = "100"; // Numeric String try { int i = Integer.parseInt(s.trim()); System.out.println("int i = " + i); } catch (NumberFormatException e) { System.out.println("NumberFormatException: " + e.getMessage()); } } } |