0

Possible Duplicate:
Java Class Files filename$1.class… etc Question

I wrote a batch file to compile the java program and execute it. When I open the file location (via GUI), I see many .class files of the same file.

For example, say I have a file called "acView.java"

I see 3 compiled .class files - "acView$1.class" "acView$2.class" and "acView.class"

What do the $1 and $2 stand for? Why are they present?

The .java file is a JFrame if that's important.

Community
  • 1
  • 1
Karthik Balakrishnan
  • 4,353
  • 6
  • 37
  • 69

1 Answers1

1

The $1 simply means that class is an anonymous class and the number 1 is generated by the compiler. When you have two anonymous classes, it will have something like YourClass$1.class and YourClass$2.class in the compiled classes.

From your code, I believe you are implementing some Listener anonymously.

If you dont want compiler generate multiple classes, you move the code to normal class.

Pau Kiat Wee
  • 9,485
  • 42
  • 40