Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:11:08+00:00 2026-06-17T12:11:08+00:00

I think probably this question has been asked/answered several times before my post. But

  • 0

I think probably this question has been asked/answered several times before my post. But I couldn’t get the exact thing I am looking for, so I post it again:

I am trying to do like this:

float[][] fa2 = {{7,2}, {5,4}, {9,6}, {4,7}, {8,1}, {2,3}};
ArrayList<Float[]> AF = new ArrayList<Float[]>();
AF = Arrays.asList(fa2);

But it is giving an error:

Type mismatch: cannot convert from List<float[]> to ArrayList<Float[]>

I understand the reason for the error but what is the most convenient way to do the conversion in Java ?

This is the easiest way that I can think of. Is there something better / more convenient ?

float[][] fa2 = {{7,2}, {5,4}, {9,6}, {4,7}, {8,1}, {2,3}};
ArrayList<Float[]> AF = new ArrayList<Float[]>(fa2.length);
for (float[] fa : fa2) {
    //initialize Float[]
    Float[] Fa = new Float[fa.length];
    //copy element of float[] to Float[]
    int i = 0;
    for (float f : fa) {
        Fa[i++] = Float.valueOf(f);
    }
    //add Float[] element to ArrayList<Float[]>
    AF.add(Fa);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:11:09+00:00Added an answer on June 17, 2026 at 12:11 pm

    As you’re converting from float[] to Float[] you have to do it manually:

    float[][] fa2 = {{7,2}, {5,4}, {9,6}, {4,7}, {8,1}, {2,3}};
    ArrayList<Float[]> AF = new ArrayList<Float[]>();
    for(float[] fa: fa2) {
        Float[] temp = new Float[fa.length];
        for (int i = 0; i < temp.length; i++) {
            temp[i] = fa[i];
        }
        AF.add(temp);
    }
    

    Or you could just be using float[] all the way:

    List<float[]> AF = Arrays.asList(fa2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You're probably thinking this has been asked a million times before but I think
probably this question has been asked in many forms before but still I think
I'm sure this question has been answered before, but I don't think I'm using
I realize this question has been asked several times, but I wanted to frame
Maybe my question has been asked several times, but... I have the following code
I realise that this question has probably been asked to death, but none of
I know this has probably been asked before but I can't find a specific
I'm sorry if this question has been asked before, but the idea is hard
This question has been asked a number of times, I have noted, but none
I know this question has been asked many times here and elsewhere before as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.