Languages
[Edit]
EN

Java - convert double[] to List<Double> - primitive double array to list of objects

7 points
Created by:
RomanaLittle
458

Problem description

1. Best solution - DoubleStream.of (Java 8)

Edit

Output:

2. DoubleStream.of + return ArrayList (Java 8)

Edit

Return required implementation eg ArrayList or HashSet

Output:

3. Explicit iteration over array (before Java 8)

Edit

Output:

4. Doubles.asList (Guava)

Edit

Output:

5. ArrayUtils.toObject (Apache commons lang3)

Edit

Output:

Summary - in java we can convert double[] to List<Double> by:

Edit
  1. Best solution - DoubleStream.of (Java 8)
  2. DoubleStream.of + return ArrayList (Java 8)
  3. Explicit iteration over array (before Java 8)
  4. Doubles.asList (Guava)
  5. ArrayUtils.toObject (Apache commons lang3)

Reference

Edit
  1. DoubleStream.of - Java 8 docs
  2. Doubles.asList - Guava docs
  3. ArrayUtils.toObject - Apache commons lang3 docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java conversion

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join