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 3 of 3

Thread: infinity output and cannot return value

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

    Default infinity output and cannot return value

    import java.io.Console;
    import java.net.InetAddress;

    public class MyResolvingDNS1
    {
    public static void main(String args[]) throws Exception
    {
    Console cons = System.console();
    System.out.println("Enter url or type exit");
    String dns = cons.readLine();

    while(!dns.equals("exit"))
    {
    InetAddress addr = InetAddress.getByName(dns);
    String host = addr.getHostAddress();
    System.out.println(host+" : " +dns);
    }
    }
    }









    expected output:

    Enter url or type exit
    Google
    74.125.135.105 : Google
    Enter url or type exit
    exit


    but i cant do like that output ..
    somebody please help


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    972
    Thanks
    7
    Thanked 205 Times in 181 Posts

    Default Re: infinity output and cannot return value

    If you want to print the prompt and assign a new value to dns you had better put code to do that inside the loop. Otherwise the prompt only gets printed once, and dns never changes its value.

    --- Update ---

    accidental dup. I'll try and merge with the other thread

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: infinity output and cannot return value

    alreay stuck


    --- Update ---

    im alredy stuck
    please help

Similar Threads

  1. Replies: 19
    Last Post: March 15th, 2013, 04:11 PM
  2. how could I output to a text area the output of a method
    By mia_tech in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 12th, 2012, 08:49 PM
  3. return;
    By tarkal in forum Java Theory & Questions
    Replies: 3
    Last Post: November 26th, 2011, 10:53 AM
  4. Return Object does not return the expected output
    By Nour Damer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 13th, 2011, 08:24 AM