sandalone
sandalone

Reputation: 41759

Android or Java class naming with $ symbol

I'm reviewing a certain project and I see that there are many classes with the same name, but with a dollar ($) symbol at the end + increasing number. For example

Class.java
Class$1.java
Class$2.java
Class$n.java
OtherClass.java
OtherClass$1.java
OtherClass$n.java

What does it mean?

Upvotes: 13

Views: 3035

Answers (2)

Nikolay Ivanov
Nikolay Ivanov

Reputation: 8935

AFAIK if it's has number it's an anonymous inner class, if it has a name after $ sign it means just inner class.
Edit: More about how compiler handles you can see here

Upvotes: 14

Nanne
Nanne

Reputation: 64409

The dollar sign is used by the compiler for inner classes. I thought it would be strange to manually make classes/files with those names though: As far as I know it's a compiler thing.

Upvotes: 3

Related Questions