Take different values from a String and convert them to Double Values

后端 未结 5 698
孤街浪徒
孤街浪徒 2021-01-27 09:10

In my code, I\'m asking the user to input three different values divided by a blank space. Then, those three different values I would like to assign them to three different

5条回答
  •  孤独总比滥情好
    2021-01-27 09:56

    You could first split the input using String.split and then parse each variable using Double.parseDouble Double.parseDouble to read them into a Double variable.

    String[] params = newDimensions.split(" ");
    newHeight = Double.parseDouble(params[0]);
    newWidth = Double.parseDouble(params[1]);
    

提交回复
热议问题