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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:37:32+00:00 2026-06-09T23:37:32+00:00

I have a list of names in an array, and there is some redundancy

  • 0

I have a list of names in an array, and there is some redundancy in it. I was able to get only unique names to print, but I need a way to print the first line, skip the printing however many times there was a redundancy, then continue printing the next name (all redundant instances were always next to eachother). Here is what I have for that part so far:

int x = 1;
int skipCount = 0;
while (x<i){
  if (titles[x].length() == titles[x-1].length()){
   //do nothing 
    skipCount++;
  }
  else{
    System.out.printf("%s\n", titles[x]);
  }
  x++;
}

So basically, how would I go about skipping the else statement ‘skipCount’ times, then have it start again? I haven’t found much about this and am relatively new to java.

  • 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-09T23:37:34+00:00Added an answer on June 9, 2026 at 11:37 pm

    Why not just use a Set? 😉

    final Set<String> set = new HashSet<>(Arrays.asList(titles));
    for (final String title : set) {
      /* title is unique */
      System.out.println(title);
    }
    

    Some of the changes include using println rather than printf("%s\n", ...), which is just clearer, and using an enhanced for loop, instead of manually tracking the position in the array in a loop.

    To be honest, you might consider using a Set<String> in place of String[] for titles in the first place.

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

Sidebar

Related Questions

Is there a way to get a list of the argument names in a
I want to have a List or Array of some sort, storing this information
I have several CONST's defined on some classes, and want to get a list
I have an array, with some names (String) in it. 1.) I want to
Is there any good way in Windows Forms Designer to have an array (or
Aside from parsing the function file, is there a way to get the names
I have an array list named newSymptomList which contains a list of Symptom id's
I have list of screen names that can be filtered by letter. The Issue
I have a list of names: ['john smith', 'sally jones', 'bob jones'] I want
I have a list of names from Facebook in my uitableview , when user

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.