A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/1205 below:

[java] Improve ConstantsInInterface message to mention alternatives · Issue #1205 · pmd/pmd · GitHub

Affects PMD Version: 6.5.0-SNAPSHOT

Rule: ConstantsInInterface

Description:

Avoid constants in interfaces. Interfaces should define types, constants are implementation details better placed in classes or enums. See Effective Java, item 19.

suggests to place constants in enums. I assume that doesn't imply to remove the static modifier and was wondering how that's possible since placing anything before the enum listing causes an identifier expected compilation error and placing them after the listing causes an illegal forward reference (compilation) error. Placing them in a private interface as suggested (as only solution) in https://stackoverflow.com/questions/23608885/how-to-define-static-constants-in-a-java-enum causes the ConstantsInInterface to fail again. It'd be nice to see the solution from Effective Java in the docs (it shouldn't be an issue to rephrase it and add a citation to the original).

Code Sample demonstrating the issue:

I can provide one if it's really necessary.

Running PMD through: Maven


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4