如何在一行中将String Array转换为Double Array [英] How to convert String Array to Double Array in one line

查看:111
本文介绍了如何在一行中将String Array转换为Double Array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个字符串数组:

String[] guaranteedOutput = Arrays.copyOf(values, values.length,
String[].class);

所有String值都是数字。数据应转换为 Double []

All the String values are numbers. The data should be converted to a Double[].

问题

Java中是否有单行解决方案来实现这一点,或者我们需要循环并将每个值转换为Double?

Question
Is there a one line solution in Java to achieve this or we need to loop and convert each value to a Double?

推荐答案

创建一个使用循环实现它的方法,然后调用你的方法,你将拥有一个单行解决方案。

Create a method implementing it using a loop, then call your method, and you'll have a one-line solution.

Java API中没有buit-in方法可以做到这一点。

There is no buit-in method in the Java API to do that.

这篇关于如何在一行中将String Array转换为Double Array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆