Results 1 to 2 of 2
  1. #1
    DanK is offline Member
    Join Date
    Dec 2008
    Posts
    10
    Rep Power
    0

    Default Another beginner question for AP test

    WHAT IS THE OUTPUT WHEN printNumbers(3) IS CALLED IN:

    public void printNumbers(int n)
    {
    for(int i =1; i<=n-1; i++)
    printNumbers(i);
    System.out.print(n + " ");
    }


    I know the answer is 1 1 2 3, but why is it that?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    best to walk through the code on paper and you'll see why.

Similar Threads

  1. Beginner Java question
    By DanK in forum New To Java
    Replies: 3
    Last Post: 04-27-2009, 05:29 AM
  2. almost done...beginner needs help plz..
    By shongo in forum New To Java
    Replies: 15
    Last Post: 11-10-2008, 09:14 AM
  3. Basic Question from Networking Beginner
    By JDCAce in forum Networking
    Replies: 7
    Last Post: 10-10-2008, 09:29 PM
  4. Confused beginner with Rectangle type question
    By sigssoft in forum New To Java
    Replies: 2
    Last Post: 10-08-2008, 03:56 AM
  5. Replies: 0
    Last Post: 04-05-2008, 01:38 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
  •