In the following code :
enum Rank {
FIRST(20), SECOND(0), THIRD(8);
Rank(int value) {
System.out.print(value);
}
}
public static void main (String[] args) {
}
This gives the following output: 2008 If however the main method is declared in some other class like this:
class XYZ
{
public static void main (String[] args) {
}
There is no output. What is the difference between main in enum and main in the class?
Aucun commentaire:
Enregistrer un commentaire