public class StringToPrimitive {
public static void main(String[] args) {
String stringValue = "123";
int intValue = Integer.parseInt(stringValue);
System.out.println("转换为 int: " + intValue);
double doubleValue = Double.parseDouble(stringValue);
System.out.println("转换为 double: " + doubleValue);
float floatValue = Float.parseFloat(stringValue);
System.out.println("转换为 float: " + floatValue);
long longValue = Long.parseLong(stringValue);
System.out.println("转换为 long: " + longValue);
boolean booleanValue = "true".equalsIgnoreCase(stringValue);
System.out.println("转换为 boolean: " + booleanValue);
}
}