Getting a double out of a string

前端 未结 8 1357
温柔的废话
温柔的废话 2020-12-10 15:15

i have a string containing the following: \"Did It Your Way, 11.95 The History of Scotland, 14.50, Learn Calculus in One Day, 29.95\" is there any way to get the doubles fro

8条回答
  •  一整个雨季
    2020-12-10 15:33

    Here is how I did it when I was getting input from a user and didn't know what it would look like:

        Vector foundDoubles = new Vector();
    
        Scanner reader = new Scanner(System.in);
        System.out.println("Ask for input: ");
    
        for(int i = 0; i < accounts.size(); i++){
            foundDoubles.add(reader.nextDouble());
        }
    

提交回复
热议问题