wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What are Compiler time Constants? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What are Compiler time Constants?" Watch "What are Compiler time Constants?" New topic
Author

What are Compiler time Constants?

siva prasaad
Greenhorn

Joined: Jan 10, 2007
Posts: 23
What is difference in the following declarations

int i=5;

int i;
i=5;

Also what are compile time constants.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Compile-time Constants from the JLS.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
siva,
What is difference in the following declarations
int i=5; //1
and
int i; i=5;//2

I am not clear about what difference you are seeking for anyway here is the difference between the two.There are various places of declarion of variable in a class body.
//1 can be declared at instance initializers,in static block,in instance block,in constructors,method body,for-loop body etc.
//2 can not be initialized as instance initializers otherwise can be initialized at the places where // can be.


~Sanjeev Singh<br />SCJP 1.5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What are Compiler time Constants?
 
Similar Threads
Performance: Constants vs Hard-Coded Text
how compiler detects unreachable code and what are compile time constants?
compile time constants
complie time constants
I dont understand switch case statement