There
are two basic ways to convert String to integer in Java.
1. Using
Integer.parseInt method.
public class IntToString { public static void main(String args[]){ String str = "123"; int i = Integer.parseInt(str); System.out.println(i); } }
2. Using
Integer.valueOf() method
public class IntToString { public static void main(String args[]){ String str = "123"; int i = Integer.valueOf(str); System.out.println(i); } }
No comments:
Post a Comment