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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:51:59+00:00 2026-06-10T01:51:59+00:00

Okay so I am using the JavaMail library and I am trying to fetch

  • 0

Okay so I am using the JavaMail library and I am trying to fetch certain message numbers. I want to do it efficiently and not have to loop twice over something… Anyways my question to you is: How can I create an array that starts at index x and ends at index x - 11 without looping?

  • 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-10T01:52:01+00:00Added an answer on June 10, 2026 at 1:52 am

    If you want to create and populate an array, you have basically three options:

    1. Write the values explicitly: int[] nums = new int[] { 0, 1, 2, 3, 4, ... }

    2. Use some form of for-loop: for (int i = 0; i < 10; i++) { nums[i] = i; }

    3. Create it recursively:

    int[] nums = new int[12];
    nums = populate(0, x, nums);
    
    private int[] populate(int index, int x, int[] nums) {
        if (nums.length >= index) {
            return nums;
        } else {
            nums[index] = x - index; // x-0 through x-11
            return populate(index+1, x, nums);
        }
    }
    

    Vanilla Java, without extra libraries and whatnot, doesn’t support a map function which would allow you to specify a function that would somehow auto-generate your values.

    Though, I really don’t understand why you don’t want to use a loop, especially for something trivial like this.

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

Sidebar

Related Questions

Okay I have a project that is using the android-rss library (org.mcsoxford.rss). I created
Okay so I'm not using any session variables, rather my code looks like this:
Okay; using the Umbraco CMS I have a xslt menu being generated in the
Okay so I am developing an advanced framework in PHP using MVC and want
Okay, this is a bit messy: I'm using Netbeans, and I have a main
Okay I am trying to make minecraft mods using eclipse. I used this video
Okay so basically : i have this simple example: main.cpp using namespace VHGO::Resource; std::list<BaseTable*>
Okay, so I have been using a PDO wrapper for a project I'm working
Okay, I am using (PHP) file_get_contents to read some websites, these sites have only
Okay, so I am using linq and thus I have a few var types

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.