package myenum;
import myenum.MyEnum.*
import java.io.*;
class MyClass{
public MyClass(){ System.out.println(A);}
}
enum MyEnum{
A, B, C
}
I get an compilation error. Also when I put enum into a different file,
it didnt work. I thought in 1,5 you cn import static members...
please explain
Roedy Green - 05 Feb 2006 01:48 GMT
>import myenum.MyEnum.*
The enum constants are just objects or sometimes are inner classes of
MyEnum. When you import MyEnum they come along with it.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Thomas Hawtin - 05 Feb 2006 12:18 GMT
>> import myenum.MyEnum.*
>
> The enum constants are just objects or sometimes are inner classes of
> MyEnum. When you import MyEnum they come along with it.
Enum constants are not imported along with the enum.
Within case labels the enum type is determined by the switch expression,
and used to qualify the label identifiers. You don't even need to import
the enum for that.
Import works the same for enums as for other types.
The correct syntax for static imports is:
import static myenum.MyEnum.*;
or
import static myenum.MyEnum.A;
import static myenum.MyEnum.B;
import static myenum.MyEnum.C;
The alternative is to qualify the constant with the enum type name:
import myenum.MyEnum;
...
MyEnum mine = MyEnum.A;
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
James Westby - 05 Feb 2006 03:56 GMT
> package myenum;
>
> import myenum.MyEnum.*
Should it be import myenum.MyEnum ??? A .* impiles importing all members
of a package, but MyEnum is not a package.
> import java.io.*;
>
[quoted text clipped - 13 lines]
>
> please explain
James