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

The Archive Base Latest Questions

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

I am building an array based off comparing two other arrays. But when I

  • 0

I am building an array based off comparing two other arrays. But when I initalize my third array I have to set the length. But that is making my array have null objects in some instances. Is there away I can drop the empty/null postions in the array. See my code so far below:

  private String[]  tags     = new String[] { "Mike", "Bob", "Tom", "Greg" };
  private boolean[] selected = new boolean[tags.length];
  public String[] selected_tags = new String[tags.length];

        for (int i = 0; i < tags.length; i++) {
            if (selected[i] == true){
               selected_tags[i] = tags[i];
            }
        }

I left out the code for the checkboxes that builds the Boolen selected [].

Either way if I only select 2 tags then my selected_tags[] array will be Mike, Bob, Null, Null

I need to get the Null Null out. Thanks in advance!

  • 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-23T22:47:03+00:00Added an answer on May 23, 2026 at 10:47 pm

    You can use ArrayList, instead of array.

    private String[]  tags     = new String[] { "Mike", "Bob", "Tom", "Greg" };
    private boolean[] selected = new boolean[tags.length];
    public List<String> selected_tags = new ArrayList<String>();
    
    for (int i = 0; i < tags.length; i++) {
        if (selected[i] == true){
            selected_tags.add(tags[i]);
        } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that can contain any number of elements. Each element contains
I'm parsing out an HTML table and building an array based on the row
I'm building a platform. Somewhere in my code, there's an array that looks like
I'm building a tree-based data structure and overloaded [ ] so that I can
We're building a PHP app based on Good old codeigniter framework and have run
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant
In building an ASP.NET 3.5 WAP, I'm always frustrated by the feeling that no
I'm building a controller to manage group based ACL in CakePHP and when I
I am currently building a Neural Network library. I have constructed it as an
I'm looking to select a collection of elements based on an array of ID

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.