Q
qazmlp
I wrote the following code to get more type-safe C++-equivalent enum in Java.
Whenever I compile this code, 3 class files are generated. Why?
testClass$1.class
testClass$State.class
testClass.class
I expected only 1 class, 'testClass.class' to be generated. I do not understand
why other two classes(mainly testClass$1.class) are generated additionally.
Please clarify.
------testClass.java------
public class testClass
{
public static class State
{
private final String StateStr ;
private State(String StateStr ) { this.StateStr = StateStr ; }
public String toString() { return StateStr ; }
public final boolean equals(Object that)
{
return super.equals(that);
}
public final int hashCode()
{
return super.hashCode();
}
}
public static final State STATE_ONE = new State( "STATE_ONE" ) ;
public static final State STATE_TWO = new State( "STATE_TWO" ) ;
}
------testClass.java------
Whenever I compile this code, 3 class files are generated. Why?
testClass$1.class
testClass$State.class
testClass.class
I expected only 1 class, 'testClass.class' to be generated. I do not understand
why other two classes(mainly testClass$1.class) are generated additionally.
Please clarify.
------testClass.java------
public class testClass
{
public static class State
{
private final String StateStr ;
private State(String StateStr ) { this.StateStr = StateStr ; }
public String toString() { return StateStr ; }
public final boolean equals(Object that)
{
return super.equals(that);
}
public final int hashCode()
{
return super.hashCode();
}
}
public static final State STATE_ONE = new State( "STATE_ONE" ) ;
public static final State STATE_TWO = new State( "STATE_TWO" ) ;
}
------testClass.java------