Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to convert queue to double[][] in java? without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
I am trying to convert queue<double[]>
to double[][]
using java 8 stream.
There are lots of literatures showing a way to convert queue<double> to double[]
in many ways but I failed to convert the double[]
to double[][]
.
How to achieve issue above?
Answer
You can use this method queue.toArray(new Double[0][0]);
.
Be careful.Do not use nonparametric overloaded method queue.toArray()
.Because it can’t convert to Double[][]
but Obejct[]
.
For example:
LinkedBlockingQueue<Double[]> linkedBlockingQueue = new LinkedBlockingQueue<>(); linkedBlockingQueue.put(new Double[]{1.1, 1.2}); linkedBlockingQueue.put(new Double[]{2.1, 2.2}); Double[][] doubleTwoDimensionArray = linkedBlockingQueue.toArray(new Double[0][0]);
The
new Double[0][0]
only be used to appoint the type of conversion.
We are here to answer your question about How to convert queue to double[][] in java? - If you find the proper solution, please don't forgot to share this with your team members.