Java: Enum parameter in method

后端 未结 7 1780
小鲜肉
小鲜肉 2020-12-29 03:54

I have a method lets say:

private static String drawCellValue(
    int maxCellLength, String cellValue, String align) { }

and as you can no

7条回答
  •  自闭症患者
    2020-12-29 04:15

    I am not too sure I would go and use an enum as a full fledged class - this is an object oriented language, and one of the most basic tenets of object orientation is that a class should do one thing and do it well.

    An enum is doing a pretty good job at being an enum, and a class is doing a good job as a class. Mixing the two I have a feeling will get you into trouble - for example, you can't pass an instance of an enum as a parameter to a method, primarily because you can't create an instance of an enum.

    So, even though you might be able to enum.process() does not mean that you should.

提交回复
热议问题