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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:30:04+00:00 2026-06-15T21:30:04+00:00

I am new to java and am doing a project using Java. I have

  • 0

I am new to java and am doing a project using Java.

I have an IP( for ex: 192.168.0.10) and a subnet mask (let us say, 255.255.255.0). I need a list of all the ip addresses in this sub-net. What I can think of best is the naive solution(in which I have to deal with bits and all). Does anyone know a better/e.legant way of doing this.

If we consider the example we will have list of ip’s as 192.168.0.1. 192.168.0.2, 192.168.0.3, ..... , 192.168.0.254

Any help appreciated.

[Edit] Naive approach I have thought of:

Construct a integer by considering the ip address you have and the subnet. In our case it would be this in binary representation 11000000.10101000.00000000.00000000 (dots are added for readability). Increment this number by 1 till the 24 bits from left toggles. The first tile it toggles we have generated all numbers which can be possible ip in this subnet. Now the task is to generate ip from a 32 bit number which can be done by writing a function which extracts 8 bits at a time.

  • 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-15T21:30:05+00:00Added an answer on June 15, 2026 at 9:30 pm

    There is Apache Commons SubnetUtils

    SubnetUtils utils = new SubnetUtils("192.168.0.10", "255.255.255.0");
    String[] addresses = utils.getInfo().getAllAddresses();
    

    getHighAddress and getLowAddress might be very useful to you. See more details in docs.

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

Sidebar

Related Questions

In a Java project I am coding I have ended up using methods that
I'm pretty new to Java and I'm finishing my first project using it. Basically
I'm doing another Java project for my class. In this assignment, we have to
I am using a Java Project that gives an user interface for doing some
I'm new to Java Web Services, so I might be doing things wrong. I'm
When I start a new Java project in eclipse, the first popup screen allow
We are starting a new Java EE project and am looking for suggestions regarding
When creating a new Java project in IntelliJ IDEA, the following directories and files
I am starting a new Java web project that will be worked on by
We are starting a new java web-project with Cassandra as the database. The team

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.