public class ConvertStrToNum { public static void main(String[] args) { int i; double x; String s; s = "123"; // Cannot be used in calculation i = Integer.parseInt(s); // Convert num str to int i = i + 1; // Now can be used in calc s = "3.14"; // Cannot be used in calculation x = Double.parseDouble(s); // Convert num str to DOuble x = x + 1; // Now can be used in calc // i = Integer.parseInt("3.14"); } }