简体   繁体   English

如何将字符串转换为双数组?

[英]how to convert string to a double array?

i have made a method called simpleDescriptive to calculate a values inside a double array.我创建了一个名为 simpleDescriptive 的方法来计算双精度数组中的值。 now the issue is that before i used to get my data from the editText field Using "parseInt /parsedouble(field.getTex().toString());"现在的问题是,在我以前使用“parseInt /parsedouble(field.getTex().toString());”从editText字段获取数据之前but now the problem is how to get my inserted double/int array values from the editText and display is to some where?但现在的问题是如何从 editText 中获取我插入的 double/int 数组值并显示到某个位置? this is the code which i have sniped from my android studio这是我从我的 android studio 中截取的代码

在此处输入图片说明

Your myArray is not an array.您的 myArray 不是数组。

Assuming your user enters a series of numbers separated by spaces, you can do:假设您的用户输入一系列由空格分隔的数字,您可以执行以下操作:

Replace:代替:

double myArray = Double.parseDouble(mdiPlayText.getText().toString());

by:经过:

String[] numbers = mdiPlayText.getText().toString().split(" ");
        double[] myArray = new double[numbers.length];
        for (int i = 0; i <numbers.length ; i++) {
            myArray[i] = Double.parseDouble(numbers[i]);
        }

... and of course error checking etc. ...当然还有错误检查等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM