Results 1 to 5 of 5
  1. #1
    loja11 is offline Member
    Join Date
    Jan 2011
    Posts
    18
    Rep Power
    0

    Default where is 6 coming from

    when i run this code, i get 6 and 7. Where is 6 coming from?

    tks

    public class Ouch {

    static int ouch = 7;

    public static void main(String[] args) {
    new Ouch().go(ouch);
    System.out.print(" " + ouch);
    }

    void go(int ouch) {
    ouch++;
    for (ouch = 3; ouch < 6; ouch++)
    ;
    System.out.print(" " + ouch);

    }
    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: where is 6 coming from

    for (ouch = 3; ouch < 6; ouch++)
    ;
    System.out.print(" " + ouch);

  3. #3
    loja11 is offline Member
    Join Date
    Jan 2011
    Posts
    18
    Rep Power
    0

    Default Re: where is 6 coming from

    Quote Originally Posted by eRaaaa View Post
    for (ouch = 3; ouch < 6; ouch++)
    ;
    System.out.print(" " + ouch);
    but the for statement is empty, how is it affecting the print statment below?

  4. #4
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: where is 6 coming from

    yes but the loop runs still couch(local couch) is less than 6 (after the loop couch(local) is 6!)

  5. #5
    loja11 is offline Member
    Join Date
    Jan 2011
    Posts
    18
    Rep Power
    0

    Default Re: where is 6 coming from

    Quote Originally Posted by eRaaaa View Post
    yes but the loop runs still couch(local couch) is less than 6 (after the loop couch(local) is 6!)
    thanks eRaaaa

Similar Threads

  1. i cant undersatand y this error is coming
    By RajeshReddy in forum AWT / Swing
    Replies: 0
    Last Post: 07-21-2011, 02:53 PM
  2. Jax is coming to the us!!!
    By blease87 in forum Reviews / Advertising
    Replies: 0
    Last Post: 03-04-2011, 12:21 PM
  3. Please help output not coming
    By majin_harish in forum New To Java
    Replies: 2
    Last Post: 02-05-2009, 09:45 AM
  4. Why is the answer not coming out
    By anonymous18 in forum New To Java
    Replies: 4
    Last Post: 11-12-2008, 03:10 AM
  5. How can i know from which jsp request is coming?
    By vishnujava in forum Java Servlet
    Replies: 1
    Last Post: 08-06-2008, 01:13 PM

Posting Permissions

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