Multiple .class files generated for a class?


Multiple .class files generated for a class?



Out of curiosity, why are sometimes multiple Java .class files generated for a class after compilation? For example, my application has six classes. For one class, a total of 10 .class files has been generated, starting from MyClass#1 up to MyClass#10.




What should I name my PHP class file? [closed]

1:



Dynamically building/loading a class library in PHP
These are for inner classes and static nested classes.


Dynamically call a static variable (array)
The ones with numbers are anonymous inner classes..
How do I list all fields of an object in Objective-C?
For example:.
Is it okay to pass a class object to another class? PHP
 class Foo {    class Bar { }    static class Baz { }    void run() {       Helper t = new Helper() {          int helpMethod() {             return 2;          }       };     } } 
This will produce class files Foo.class, Foo$Bar.class, Foo$Baz.class and Foo$1.class (for the implementation of the Helper interface).
The difference between Classes, Objects, and Instances


Binding a ComboBox to an enum nested in a class


PHP Classes: when to use :: vs. ->?

2:


You get more .class fils from a single source file if.
  • the class contains inner classes or static inner classes.

    Inner classes can nest.

    Their names are <outer class name>$<inner class name>..
  • inner interfaces which are always static..
  • anonymous inner classes (which in fact are plain inner classes without a name).
  • package access interfaces and classes before and after your main class.

    You can have an arbitrary number of package access classes and interfaces in a single Java source file.

    Usually small helper objects that are only used by the class are just put into the same file..


3:


One java source file can generate multiple class files, if your class contains inner classes.

Anonymous inner classes are represented by your numbered class files..


4:


Every class in java belongs to a .java-file, but a .java-file can contain multiple classes.

That includes inner and anonymous classes.

The .class-files generated for inner classes contain a '$' in their name.

Anonymous inner classes get numbers..


5:


More than one class will be generated on compilation, Only if your class is having inner class.. refer: http://stackoverflow.com/questions/380406/java-inner-class-class-file-names.



94 out of 100 based on 54 user ratings 454 reviews