Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25
  1. #21
    Slaughterman is offline Member
    Join Date
    Sep 2009
    Posts
    11
    Rep Power
    0

    Default

    But I don't understand... Since the inp inside the do seems to be cut from any outside-do checking, how could the while check it's value if it can't even recognize the inp itself.

    I did as you say, and still i have an error 'duplicate local variable'.

    connect("127.0.0.1",2002);
    String inp = "";
    do
    {
    System.out.println("Enter your name:");
    String inp = readKeyboard();
    send(inp);
    System.out.println(receive());
    }
    while(!inp.equals("bye"));

    System.exit(0);

  2. #22
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Java Code:
    String inp = "";
    do {
       inp = readKeyboard();
       ...
    In this case, we don't create a new inp. We use the same one we created before the do statement.

  3. #23
    Slaughterman is offline Member
    Join Date
    Sep 2009
    Posts
    11
    Rep Power
    0

    Default

    I'm really a newbie, it's almost embarrassing...

    Thanks r035198x for your patience :) .

  4. #24
    Dieter's Avatar
    Dieter is offline Member
    Join Date
    Sep 2009
    Posts
    91
    Rep Power
    0

    Default

    what about enter "break;" if you want to exit the loop ?
    Programming today is a race between software engineers striving to build bigger and better idiot proof programs,and the Universe trying to produce bigger and better idiots...

  5. #25
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Quote Originally Posted by Slaughterman View Post
    I'm really a newbie, it's almost embarrassing...

    Thanks r035198x for your patience :) .
    It's ok.
    You'll find that I'm not a very patient person though.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. [newbie]
    By jon80 in forum New To Java
    Replies: 10
    Last Post: 07-07-2009, 12:10 PM
  2. Newbie Help
    By mattkid in forum New To Java
    Replies: 4
    Last Post: 03-25-2009, 04:55 AM
  3. newbie newbie newbie
    By krislogy in forum New To Java
    Replies: 9
    Last Post: 08-15-2008, 12:28 AM
  4. newbie needs help...
    By vicky08 in forum New To Java
    Replies: 2
    Last Post: 03-31-2008, 04:26 PM
  5. Newbie
    By CSnoob87 in forum Introductions
    Replies: 2
    Last Post: 02-18-2008, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •