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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:31:04+00:00 2026-05-31T13:31:04+00:00

So Basically I am generating random 10000 ip address and I wanted to store

  • 0

So Basically I am generating random 10000 ip address and I wanted to store all those ip address that are found in HashSet but according to my calculation around 6000 ip address were found but in HashSet only 700 ip address are getting stored? Is there any limitations in HashSet in terms of storing String. Any suggestions will be appreciated.

   Set<String> ipFine = new HashSet<String>();
        long runs = 10000;
            while(runs > 0) {

            String ipAddress = generateIPAddress();

            resp = SomeClass.getLocationByIp(ipAddress);

            if(resp.getLocation() != null) {

                 ipFine.add(ipAddress);
                        }

               runs--;

         }
  • 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-31T13:31:04+00:00Added an answer on May 31, 2026 at 1:31 pm

    As far as you’re concerned, there is no limit (the limit is the max size of an array, which is 2**31).

    However, Sets only store unique values, so my guess is that you only generated 700 unique addresses.

    Modify your code as follows:

    if(resp.getLocation() != null) {
        if (ipFine.add(ipAddress)) { // add() returns true if the value is unique
            runs--; // only decrement runs if it's a new value
        }
    }
    

    This modification will mean you’ll keep looping until you get 10000 unique values.

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

Sidebar

Related Questions

Right now I'm generating a random enumerator using boost's random library. Basically I'm using
Not sure if the title makes sense sorry... basically I'm generating Word documents that
I am displaying some text in a JLabel. Basically I am generating that text
Basically, when generating plots with matplotlib, The scale on the y-axis goes into the
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I’ve heard that certain conditions will cause .NET to blow past the finally
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am generating text using this : for i in xrange(100): sys.stdout.write(alphabet[bisect.bisect(f_list, random.random()) -
I want to basically run an url which i would be generating behind the
I have made the following webpage for generating interactive todo lists: http://robert-kent.com/todo/todo.php Basically, the

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.