Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

two class files for one java file

 
feroz muhamed
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
please look at this.when i am compiling java file which importing awt package and extends any awt components, two class files one with original claas name and other with classname$1 like this. how this happens please help.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The other one is probably generated because you have an annonymous inner class in the original class, and the compiler gererates an articficial name for it.
 
feroz muhamed
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks cindy really only now i identified this.if u know the naming criteria for this(ie sometimes myclass$mybuuton,or myclass$B like that)please...
 
Peter Kleczka
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Member classes are written to a file of the form EnclosingClass$MemberClass.class
Anonymous inner clases are written in the form
EnclisingClass$1.class and are numbered sequentially
for multiple anonymous classes.
When anonymous inner classes appear inside of other
anonymous inner classes, the pattern is Outer$1.class
not Outer$Inner$1.class.
HTH
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic