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'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 string based on selected checkboxes. I wrote a statement that will
We're building a PHP app based on Good old codeigniter framework and have run
I'm building a game in AS3 based off of Gary Rosenzweig's latest Actionscript 3
I have an array that can contain any number of elements. Each element contains
I'm looking for advice on something I'm building: I have a PHP app that
Often, I am building an array by iterating through some data, e.g.: my_array =
I´m building a jquery animation from a multidimensional array, and in the callback of
building a site using PHP and MySQL that needs to store a lot of

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.