Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android or Java class naming with $ symbol

Tags:

java

android

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?

like image 475
sandalone Avatar asked Mar 05 '11 12:03

sandalone


2 Answers

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

like image 106
Nikolay Ivanov Avatar answered Sep 29 '22 05:09

Nikolay Ivanov


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.

like image 38
Nanne Avatar answered Sep 29 '22 04:09

Nanne