13.How to convert String to Object.
💡Code:
public class StringToObjectConversion7078 {
public static void main(String[] args) {
// Example String
String numberString = "123";
// Convert String to Integer using parseInt() method
Integer intValue = Integer.parseInt(numberString);
// Print the converted Integer object
System.out.println("Converted Integer: " + intValue);
// Similarly, you can convert to other types like Double, Float, etc.
// Example: Convert String to Double
String doubleString = "456.789";
Double doubleValue = Double.parseDouble(doubleString);
System.out.println("Converted Double: " + doubleValue);
}
}
📸Output :