我正在使用 split 来划分字符串输入。前 3 个很好用,因为它们是字符串,但最后一个输入是双精度。知道我应该如何进行这项工作,以便字符串拆分可以将结果 [4] 传递给 ArrayList 中的双精度数吗?
Scanner catin = new Scanner(System.in);
System.out.print("Enter the Name, Breed, Color, and Weight of the Cat: ");
String test = catin.nextLine();
String[] result = test.split(",");
Cat c4 = new Cat(result[1], result[2], result[3], result[4]);