aspose file tools*
The moose likes Beginning Java and the fly likes compile time constant. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compile time constant." Watch "compile time constant." New topic
Author

compile time constant.

Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

What these are?
Mark Newton
Ranch Hand

Joined: Jan 31, 2006
Posts: 129
Constants. At compile time.
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

but, which ones? gime some example please,

and.. which no? gime som example too please.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39865
    
  28
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

this term generally refers to some variable that YOU create. the compiler is able to know what it will be.

something like

int x = getValueFromUser()

would not be a constant, because it could change. even

final int x = getValueFromUser()

would not be a COMPILE


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

I Get it!!

Thank you Fred and Campbell
[ January 18, 2008: Message edited by: Milton Ochoa ]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
You can also find detailed rules about exactly what is considered a compile-time constant expression in JLS 15.28.


"I'm not back." - Bill Harding, Twister
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3355

A compile time constant is a value which can be very well identified (determined) during the compilation time itself. It does NOT need to wait till runtime.

Some examples are: string literals whatever you type within double quotes (eg. "Sample String"), all constant values like INTEGER.MAX_VALUE etc.,


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: compile time constant.