"Il y a peu de choses qui me soient impossibles..."
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Stephan van Hulst wrote:Values that are not known until runtime simply are not constants.
Writing GREEN to file.
Done writing.
Reading a color from file.
It is GREEN, duh!
Daniel Cox wrote:By exception, I was referring to your statement "Values that are not known until runtime simply are not constants". An enum constant's "value" (identity) is not known until runtime but it is regarded as a constant since it stays constant at runtime.
Agree with Bear.Bear Bibeault wrote:. . . values that are set at the outset of the run . . . and are never changed are "constants". . . .
Stephan van Hulst wrote:Who says their value isn't known?
Bear Bibeault wrote:...values that are set at the outset of the run...and are never changed are "constants"...
Daniel Cox wrote:I don't think that an enum constant is technically a compile-time constant which to me implies that its value is not known at compile-time.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Campbell Ritchie wrote:Anyway, enum constants don't count as constant expressions...
Junilu Lacar wrote:so does this mean that nobody really gives a hoot about Netbeans' grousing about naming conventions for constants vs non-constants?
"Il y a peu de choses qui me soient impossibles..."
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Junilu Lacar wrote:so does this mean that nobody really gives a hoot about Netbeans' grousing about naming conventions for constants vs non-constants?
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Paul Clapham wrote:I know in Eclipse there's a page where you can configure all of those nagging warnings as "Error", "Warning", or "Ignore". Whether Netbeans has this option, I don't know.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Daniel Cox wrote:Makes sense to me since enum constants are objects and objects are not created at compile-time.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Stephan van Hulst wrote:...NetBeans doesn't necessarily grouse about using all caps for constants: Java's naming convention is to use all caps for variables that are static and final.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
To theWinston Gutkowski wrote:. . . Enums are a bit of an odd bird, since they look like (and probably are) objects, but several things about them suggest that they're static; . . .
That means that an enum contant is a static final field of its class and is also an instance of that class, named as the enum. If it is an instance, then it is an object in its own right. You can also call Object methods on it and do some reflection:-You can also tell the enum is a static member of that class because it is not called on an object reference.That LS link §8.9.3 wrote:For each enum constant c declared in the body of the declaration of E, E has an implicitly declared public static final field of type E that has the same name as c. The field has a variable initializer consisting of c, and is annotated by the same annotations as c.
Winston Gutkowski wrote:
Daniel Cox wrote:Makes sense to me since enum constants are objects and objects are not created at compile-time.
They aren't? What about String literals?
When a .java file is compiled into a .class file, any String literals are noted in a special way, just as all constants are. When a class is loaded (note that loading happens prior to initialization), the JVM goes through the code for the class and looks for String literals. When it finds one, it checks to see if an equivalent String is already referenced from the heap. If not, it creates a String instance on the heap and stores a reference to that object in the constant table.
"Il y a peu de choses qui me soient impossibles..."
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Junilu Lacar wrote:My guess would be that static initialization block, specifically line 13 (or line 35). Why? I couldn't guess NetBeans' stated reason for grousing but the root cause would be a shortcoming(?) in its style checking rules in accounting for this scenario.
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:Stephan and Winston (among others) have raised some doubts in me about how well I really understand the use of static variables (they do that to me all the time, too... it gets depressing
). Most likely, I am misusing my statics in some way that reflects my continuing inability to shuck off the vestiges of my procedural coding style.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck
How to Ask Questions | How to Answer Questions | Format Your Code
Junilu Lacar wrote:Looking back at your code, I have to question the choice to expose MAX_PLAYERS rather than something like getNumberOfJoysticks(). Do you really want that value globally exposed? Does it need to be?
"Il y a peu de choses qui me soient impossibles..."
Stevens Miller wrote:I deliberately tried to make the question a bit more abstract than it actually is [...] In my real-world situation, I am writing Java wrappers for the XInput API functions...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Yes, my master! Here is the tiny ad you asked for:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
|