2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by iamcreasy
1

$ is used as a separation marker for denoting inner classes. For e.g. consider the following class:

public class MyWidget {
	
	static class Oh {
	}
	
	public void doIt() {
		final Runnable r1 = new Runnable() {
			@Override
            public void run() {
            }
		};
		final Runnable r2 = new Runnable() {
			@Override
            public void run() {
            }
		};
		r1.run();
		r2.run();
	}
	
}

Here; four class files would be created:

  1. MyWidget
  2. MyWidget$Oh.class
  3. MyWidget$1.class
  4. MyWidget$2.class

Basically, the format is: OuterClassName$(InnerClassName or number in case of anonymous class).class. In the above case, since we have two anonymous Runnables created, we have $1.class and $2.class.

In case you are unaware of nested classes, more details at: http://download.oracle.com/javase/tutorial/java/javaOO/nested.html

Edited by ~s.o.s~: n/a

Votes + Comments
Perfect answer!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.