There a two ways to convert String object to integer value.
1. Using Integer.parseInt()
This method takes a String object as parameter and returns it primitive type int value.
2. Using Integer.valueOf()
This method takes a String object as parameter and returns an object of Integer class.
1. Using Integer.parseInt()
This method takes a String object as parameter and returns it primitive type int value.
String s = "100"; int i = Integer.parseInt(s); System.out.println("Integer value is " + i);
2. Using Integer.valueOf()
This method takes a String object as parameter and returns an object of Integer class.
String s = "100"; Integer i = Integer.valueOf(s); System.out.println("Integer value is " + i);
0 comments:
Post a Comment