WAP to typecast the following: String to Integer
1 year ago
OOP Java
Compile code:
class StringToInt{
public static void main(String[] args) {
// create string type variable
String data = "10";
System.out.println("The string value is: " + data);
// convert string variable to int
int num = Integer.parseInt(data);
System.out.println("The integer value is: " + num);
}
}
Output:
Dipti KC
Jan 8, 2023