java - Do I need to define an enum as 'public' in its own file so it can be recognized outside its own package? -


I have two packages- x and y.

In class X student class and grade enum.

In the Y, there is a Klass class.

Why is type student?

Do I need to define it in my file and make it public?

/ Strong>

  package x; Enum grade {A, B, C, D, F, Incomplete}; Public class student {// blah, blah, member variables, getters, setters, constructor} package y; Public Class Class {// This Enum Type is the Public Fixed Last MINIMUM_GRADE = Student.Grade.C; }  

Yes, you have to declare that enum public you will find it in your file Should not be kept.

You just have your example like student.grad. C ;

Code> Import student.grid and just use C in your code.


Comments