Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: iProblem Array and looping Ip address,How?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb iProblem Array and looping Ip address,How?

    Greetings all.
    I have a program calculation ip address like this.
    public static void main(String[]args){
            int host=450;
            String sMask="255.255.254.0";
            String[] octet;
            String IpAddress="192.168.100.0";
            octet = IpAddress.split("\\.");
            int oct1=Integer.parseInt(octet[0]);
            int oct2=Integer.parseInt(octet[1]);
            int oct3=Integer.parseInt(octet[2]);
            int oct4=Integer.parseInt(octet[3]);
            int i;
            System.out.println("Ip Address \t \tSubnet Mask");
            for(i=oct4;i<host;i++){
                System.out.println(oct1+"."+oct2+"."+oct3+"."+i+"\t \t"+sMask);
            }
        }


    print out from this program

    Ip Address Subnet Mask
    192.168.100.0 255.255.254
    192.168.100.1 255.255.254
    192.168.100.2 255.255.254
    192.168.100.3 255.255.254
    until...
    192.168.100.449 255.255.254
    :laugh: I want this program,if ip address octet 4 value "192.168.100.255",then continuing this program,like this.

    next >
    192.168.101.0 255.255.254
    192.168.101.1 255.255.254
    192.168.101.2 255.255.254
    until ...
    192.168.101.193 and Finish.

    What the lack from my program?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: iProblem Array and looping Ip address,How?

    Asked/answered at DIC.

Similar Threads

  1. Array Looping
    By LeeDD in forum What's Wrong With My Code?
    Replies: 13
    Last Post: March 19th, 2013, 02:08 PM
  2. A little help with looping my array
    By tyneframe in forum Loops & Control Statements
    Replies: 4
    Last Post: November 24th, 2012, 10:41 AM
  3. Looping through an Array.
    By kl2eativ in forum Loops & Control Statements
    Replies: 4
    Last Post: June 10th, 2011, 07:15 PM
  4. Array of contacts (address book)
    By smush in forum Collections and Generics
    Replies: 11
    Last Post: April 29th, 2010, 03:08 AM
  5. Looping through a multidimensional array
    By MysticDeath in forum Loops & Control Statements
    Replies: 2
    Last Post: October 11th, 2009, 05:41 PM

Tags for this Thread