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.


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
    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="";
            String[] octet;
            String IpAddress="";
            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");
                System.out.println(oct1+"."+oct2+"."+oct3+"."+i+"\t \t"+sMask);

    print out from this program

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

    next > 255.255.254 255.255.254 255.255.254
    until ... and Finish.

    What the lack from my program?

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    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