Menu
Question Index
...

Write a program to convert float list to float array.

Input(Float List) Output(Float Array)
[10.2, 20.3, 34.3, 56.7, 90.5, 123.8] {10.2, 20.3, 34.3, 56.7, 90.5, 123.8}
[-123.4, -562.3, -147.2, -523.1, 452.4, -254.1] {-123.4, -562.3, -147.2, -523.1, 452.4, -254.1}
[] {EMPTY LIST} null
null {NULL LIST} null


import java.util.*;
class ConvertFloatListIntoFloatArray
{
    public static void main(String s[])
    {
        ArrayList<Float> floatList = new ArrayList<Float>();
        floatList.add(12.3f);
        floatList.add(32.6f);
        floatList.add(43.7f);
        floatList.add(56.9f);
        floatList.add(98.5f);
        float[] result = convertFloatListToFloatArray(floatList);
        System.out.println("The converted float array");
        for(float inputData : result)
        {
            System.out.println(inputData);
        }

    }


        public static float[] convertFloatListToFloatArray(List<Float> inputList)
        {
            float[] result = null;
            return result;
        }

}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App