Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is dollar sign mean in the stack frames when debugging?

Tags:

java

eclipse

In the stack using Eclipse, sometimes I saw

Manager$2.run() line : 278

What does $2 mean here?

like image 325
Adam Lee Avatar asked Jun 16 '12 14:06

Adam Lee


1 Answers

It is anonymous class.

An anonymous class is a local class without a name. An anonymous class is defined and instantiated in a single succinct expression using the new operator.

From the method name, it might be a Runnable.run() method.

public class Manager {
    
    public static void main(String[] args) {
        new Manager();
    }
    
    public Manager() {
        //                         this is anonymous class
        //                              |
        //                              V
        Thread thread = new Thread(new Runnable() {
            
            @Override
            public void run() {
                System.out.println("hi");
            }
        });
        thread.start();
    }
}

See

  • Anonymous Classes
like image 69
Pau Kiat Wee Avatar answered Oct 16 '22 21:10

Pau Kiat Wee