enum CoffeeSize{
BIG(8), HUGE(10), OVERWHELMING(16);
CoffeeSize(int ounce){
this.ounce = ounce;
}
private int ounce;
public int getOunces(){
return ounce;
}
}
class EnumTest {
static CoffeeSize size ;
size = CoffeeSize.BIG;
public static void main(
String []args){
// size = CoffeeSize.BIG;
}
}
if I assign size after line
static CoffeeSize size ; I got a complier error "EnumTest.java": <identifier> expected at line 17, column 14
". But i assign in side main there is no compiler error.What is the difference between these two assignments. Why am I getting a compile time error if I write
static CoffeeSize size ;
size = CoffeeSize.BIG;
out side main method.