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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:47:23+00:00 2026-05-15T21:47:23+00:00

I want to add multiple BigInteger values to an ArrayList . All I have

  • 0

I want to add multiple BigInteger values to an ArrayList. All I have found is examples that repeatedly add single values, each expressed on their own line of code. I’m looking for something like

ArrayList<BigInteger> array = {bigInt1, bigInt2, bigInt3};

and instead it’s:

ArrayList<BigInteger> array = new ArrayList<BigInteger>();
array.add(bigInt1);
array.add(bigInt2);
array.add(bigInt3);

Can it be done, without adding one element/line or using a for loop?

  • 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-15T21:47:24+00:00Added an answer on May 15, 2026 at 9:47 pm

    I’m not really sure what you’re after. You have four alternatives:

    1. Add items individually

    Instantiate a concrete List type and then call add() for each item:

    List<BigInteger> list = new ArrayList<BigInteger>();
    list.add(new BigInteger("12345"));
    list.add(new BigInteger("23456"));
    

    2. Subclass a concrete List type (double brace initialization)

    Some might suggest double brace initialization like this:

    List<BigInteger> list = new ArrayList<BigInteger>() {{
      add(new BigInteger("12345"));
      add(new BigInteger("23456"));
    }};
    

    I recommend not doing this. What you’re actually doing here is subclassing ArrayList, which (imho) is not a good idea. That sort of thing can break Comparators, equals() methods and so on.

    3. Using Arrays.asList()

    Another approach:

    List<BigInteger> list = new ArrayList<BigInteger>(Arrays.asList(
      new BigInteger("12345"),
      new BigInteger("23456")
    ));
    

    or, if you don’t need an ArrayList, simply as:

    List<BigInteger> list = Arrays.asList(
      new BigInteger("12345"),
      new BigInteger("23456")
    );
    

    I prefer one of the above two methods.

    4. Collection literals (Java 7+)

    Assuming Collection literals go ahead in Java 7, you will be able to do this:

    List<BigInteger> list = [new BigInteger("12345"), new BigInteger("23456")];
    

    As it currently stands, I don’t believe this feature has been confirmed yet.

    That’s it. Those are your choices. Pick one.

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

Sidebar

Related Questions

I have two g:select comboboxes that I want to add to the multiple select
I have a tab bar that I want to add to multiple activities. I
I want to add multiple borders on a single image. Is this possible through
I want to add multiple methods in that respond as the selector when a
I want to add multiple text value in text field. The values comes from
I want to add multiple columns in UITableView. I have created one CustomeTableCell with
I’m using Highcharts and I want to add multiple charts to a single page
I have a Zend_Form with multiple Multicheckbox element, the thing that I want is
I have viewport3D and I want to add multiple 3d objects defined in xaml
I want to add multiple values into an array, but I want to stop

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.