java - 如何将字节数组转换为 double 组?

标签 java

如何将此字节数组转换为 double 组。

byte[] byteArray = {1,0,0,1,0};

我喜欢不使用循环来转换它,因为这个字节数组有大量元素。

请帮助我

最佳答案

可能的“无循环”解决方案将使用 System.arraycopyArrays.copyOf ,但在这些解决方案中,您无法避免将 byte[] 转换为 double[]。问题是根据specification,这种类型转换是不可能的。 :

Given a compile-time reference type S (source) and a compile-time reference 
type T (target), a casting conversion exists from S to T if no compile-time 
errors occur due to the following rules.
[...]
If S is an array type SC[], that is, an array of components of type SC: 
[...] 
  - If T is an array type TC[], that is, an array of components of type TC, 
    then a compile-time error occurs unless one of the following is true: 
    - TC and SC are the same primitive type. 
    - [...]

使用循环。另请参阅here .

关于java - 如何将字节数组转换为 double 组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18356906/

相关文章:

java - 嵌套库 aar 文件行为

java - 使用 Maven 在 Eclipse 中以编程方式运行 testNG,无需插件

java - 为什么将 "this"传递给 Thread 构造函数不安全?

java - Android SearchView 既没有启动可搜索 Activity ,也没有调用 onNewIntent()

java - 如何从 ZipEntry 创建输入流

java - RFC5545。同时计算 RRULE 和 EXDATE (EXRULE) 的事件发生次数

Java Twitch IRC 机器人

java - 需要java中正则表达式的帮助

java - 如何在提交任何任务之前初始化固定线程池的所有线程? (Java)

java - 类中 SwingX 的 JXCollapsiblePane 正在影响该类创建的其他对象中创建的所有其他 Pane