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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:06:29+00:00 2026-06-01T20:06:29+00:00

For example: String[] someArray = {null, I want to start from here, other element,

  • 0

For example:

String[] someArray = {null, "I want to start from here", "other element", "other element"};

for(int i = 1; i < someArray.length; i++)
{
    System.out.println(someArray[i]);
}

Is there way to set the inital index of an array other than setting the first element to null?

In the for loop, I want to set i = 1.

  • 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-01T20:06:30+00:00Added an answer on June 1, 2026 at 8:06 pm

    There is no way to set the initial index of an array: it still has a 1st (index 0) element, it just happens to be null in your case. You can always start iterating from whatever index you want, but you’ll be wasting space.

    You could always make your own class…

    class WeirdIndexArray<T> {
        private final T[] internalArray;
        public final int firstIndex;
        public final int indexBound;
        public WeirdIndexArray( int firstIndex, int size ){
            internalArray = new T[size];
            this.firstIndex = firstIndex;
            indexBound = firstIndex+size;
        }
        public void set( int index, T item ){ internalArray[index-firstIndex] = item; }
        public T get( int index ){ return internalArray[index-firstIndex]; }
    }
    

    And use it…

    WeirdIndexArray<String> array = new WeirdIndexArray<>(1,3);
    
    for( int i=1; i<array.indexBound; i++ )
        array.set(i,"This is item "+i);
    

    But why would you need that in the first place?

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

Sidebar

Related Questions

I want to parse the url from a String in android. The example String
For example: string element = 'a'; IEnumerable<string> list = new List<string>{ 'b', 'c', 'd'
What is the best way to parse time from a string? Example string: this
This is the example string: User.status <> 'actived' I want this: `User`.`status` <> 'actived'
Example String : as8d79asf5.dfdg dg s dgd2011/25klsdsj jdıo84823 jhgfkasfsf 2001/26llkasdjfıo; I want to get
I want to remove comma at end if string ends with comma For example
Is it possible to convert alphabetical string into int in C#? For example string
Considering I have two arrays for example: String[] array1 = new String[10]; int[] array2=
E.g. in the following example: string commandText = string.Format(Select * from {0}, filename); How
for example string test = extract substring from a string; // extract this in

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.