Results 1 to 2 of 2
  1. #1
    raffs03 is offline Member
    Join Date
    Sep 2012
    Posts
    54
    Rep Power
    0

    Default Does calling println() method adds to the stack of a thread?

    Java Code:
    public class MyClass
    {
       
       void meth()
      {
        System.out.println("Hello");
      }
    
      public static void main()
      {
        MyClass mc = new MyClass();
        mc.meth();
      }
      
    }
    If I run this code does calling println() method adds to the stack of the thread? if so, does println() stack frame is located in the meth() stack frame or it is located directly on the main stack at the bottom of meth() stack frame?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    25

    Default Re: Does calling println() method adds to the stack of a thread?

    If you were to debug that code and step through it, when you stepped into the println() call you would see the call stack showing something like:
    println()
    meth()
    main()

    Is that what you were asking?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 6
    Last Post: 03-01-2013, 06:36 AM
  2. Replies: 3
    Last Post: 11-29-2012, 05:33 AM
  3. Calling a method on mainthread when another thread finishes
    By gauravfzd in forum Threads and Synchronization
    Replies: 5
    Last Post: 08-27-2012, 06:13 PM
  4. Why my cast has to be in println() method ?
    By fatabass in forum New To Java
    Replies: 6
    Last Post: 03-03-2012, 10:11 PM
  5. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 11:40 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
  •