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 4256958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:25:31+00:00 2026-05-21T05:25:31+00:00

I have an ArrayList of type Boolean that requires to be manipulated as a

  • 0

I have an ArrayList of type Boolean that requires to be manipulated as a boolean[] as I am trying to use:

AlertDialog builder;
builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { ... });

However, while I can create a Boolean object array, I cannot find an efficient way to covert this object array to a primitive array that the builder function calls for (the only method I can come up with is to iterate over the Object array and build a new primitive array).

I am retrieving my Object array from the ArrayList as follows:

final Boolean[] checkedItems = getBoolList().toArray(new Boolean[getBoolList().size()]);

Is there something I can do with my ArrayList? Or is there an obvious casting/conversion method that I am missing??

Any help appreciated!

  • 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-05-21T05:25:32+00:00Added an answer on May 21, 2026 at 5:25 am

    You aren’t missing anything, the only way to do it is to Iterate over the list I’m afraid

    An (Untested) Example:

    private boolean[] toPrimitiveArray(final List<Boolean> booleanList) {
        final boolean[] primitives = new boolean[booleanList.size()];
        int index = 0;
        for (Boolean object : booleanList) {
            primitives[index++] = object;
        }
        return primitives;
    }
    

    Edit (as per Stephen C’s comment):
    Or you can use a third party util such as Apache Commons ArrayUtils:

    http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/ArrayUtils.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable like that: List<Double> frameList = new ArrayList<Double>(); /* Double elements
I have list of objects type Node ( items ). And Node class has
I have a List with the following elements. List<String> numbers = new ArrayList<String>(); numbers.add(1);
I have an ArrayList , and I need to filter it (only to remove
i know virtually no java but i'm trying to learn some for this project.
Hey guys, my question is about persisting an entity in JDO. I have created
I'm writing some code that needs to process an arbitrary number of lists of
I have started to test an application on Honeycomb and get the following error
I have listview with some listadapter after click on item from list I'd like
I am having a specific problem implementing a parametrised class Parameter, but this is

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.