I found this type of code in a repository during my project work. That repository works well fine... but when i am trying to understand the code through an independent test run... giving error!!!
public enum Fruits {
static {
APPLE= new Fruits( "APPLE", 0 );
BANANA = new Fruits( "BANANA", 1 );
// and so on.
}
}
I am not able to understand the meaning of calling a constructor of enum inside enum, that too without declaring a constructor.