package nilpointer.net;
public class Demo {
public static void main(String[] args) {
String s = "p01,Name 1,4.5,123,true";
String[] result = s.split(",");
String id = result[0];
String name = result[1];
double price = Double.parseDouble(result[2]);
int quantity = Integer.parseInt(result[3]);
boolean status = Boolean.parseBoolean(result[3]);
System.out.println("Output");
System.out.println("id: " + id);
System.out.println("name: " + name);
System.out.println("price: " + price);
System.out.println("quantity: " + quantity);
System.out.println("status: " + status);
}
}
Output
id: p01
name: Name 1
price: 4.5
quantity: 123
status: false