Convert string to integer in Java
Description
The following code shows how to convert string to integer.
Example
//from w w w. j a va 2 s. c o m
public class Main {
public static void main(String[] args) {
int x, y;
x = Integer.parseInt("1");
y = Integer.parseInt("2");
System.out.println(y);
System.out.println(x);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »