Why does java compiler generates multiple .class files for single Java File?
I have written some Java code Deadlock.java
, on compiling this it generated multiple classes
Named Deadlock$someNumber.class
.
Why does this happen?
What is the significance of it?
If you have several classes in the same file (one of them is necessary public and has the same name as the file), say that in your Person.java file, you have the following
public class Person{
}
class Classroom{
}
The compiler will create a class for each class in the file Person.java
I beleive it usually does that when you use anonymous inner classes. Each of those classes will get a class file but as you declared no name for them , it gets a number. So any unnamed class declaration you created (perhaps for Runnable or Listeners etc) is probably creating those.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With