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

  • Home
  • SEARCH
  • 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 874347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:05:24+00:00 2026-05-15T11:05:24+00:00

I am new to java programming, been programing in php so I’m used to

  • 0

I am new to java programming, been programing in php so I’m used to this type of loop:

int size = mapOverlays.size();
for(int n=1;n<size;n++)
{
    mapOverlays.remove(n);
}

So I want to remove everything but the first item, so why doesn’t this work? As I get it, after removal, array keys are rearranged or not?

  • 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-15T11:05:25+00:00Added an answer on May 15, 2026 at 11:05 am

    As I get it, after removal, array keys are rearranged or not?
    Yes, the item which was on position 2 is on position 1 after you removed the item on position 1.

    You can try this:

    Object obj = mapOverlays.get(0); // remember first item
    mapOverlays.clear(); // clear complete list
    mapOverlays.add(obj); // add first item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Android & Java programming but have been programming in .NET for
I have been working on Eclipse recently. I am fairly new to java programming,
Before I start know this: I am extremely new to Java and programming. How
I'm new to Python (I have been programming in Java for multiple years now
I'm fairly new to programming and have been focussing a great deal on Java
Im somewhat new in java, been programming for about a year now and im
I have been programming in Python, PHP, Java and C for a couple or
I am new to Java programming / Android development - but I have been
I'm pretty new to Perl but have been programming in java for several months
I'm completely new to Eclipse/Java/Android programming, so this might sound like a dumb question,

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.