Computer Science Canada

Class$#.class . . . what does it mean?

Author:  Aziz [ Thu Jul 27, 2006 12:43 pm ]
Post subject:  Class$#.class . . . what does it mean?

When I compile my main proggy, it compiles all the other class it uses, I get that, but why does it spit out several different .class files?

The whole project uses these files:

code:
HourRecorder.java
PunchClock.java
PunchTime.java
PayStub.java
InOutDialog.java
PunchInOutException.java


Now, I compile HourRecorder.java, and it spits out:

code:
HourRecorder.class
HourRecorder$1.class
HourRecorder$2.class
HourRecorder$3.class
HourRecorder$4.class
HourRecorder$5.class
HourRecorder$6.class
HourRecorder$7.class
InOutDialog.class
InOutDialog$1.class
InOutDialog$2.class
InOutDialog$3.class
PayStub.class
PayStub$1.class
PunchClock.class
PunchTime.class
PunchInOutException.class


My question is, why all the files? And do I need them all? All the $# files are 1KB (not the originals). I'm ... jarring...jarring?....anyways, im making a jar file and all these are going in, it's worked before and I'm not too concerned over a extra 10KB, but why?

Author:  wtd [ Thu Jul 27, 2006 1:09 pm ]
Post subject: 

Post the code for HourRecorder.java.

Author:  wtd [ Thu Jul 27, 2006 1:13 pm ]
Post subject: 

Ah, found the source.

You create anonymous inner classes in your class.

code:
new ActionListener() {
   public void actionPerformed(ActionEvent e) {
      actionIn();
   }
}


These have to be given some unique name, so they are.

Author:  Aziz [ Thu Jul 27, 2006 2:20 pm ]
Post subject: 

Oh, okay, that makes sense. So, this is perfectly fine, right? Anonymous inner classes are good . . . right?

Author:  wtd [ Thu Jul 27, 2006 4:16 pm ]
Post subject: 

It is fine.


: