Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Complile time constant expression.

 
Mathangi Shankar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have been hearing the word compile time constant expression many a times.Can anybody share examples on this?

Like which is a compile time constant expression and which is not...

Thanks,

Mathangi.
 
prajkta patil
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"the final variables which r defined at the time of declaration " are the compile time constant expression.for example-
class abc{
final int i=3;
}
in this compiler gets the value of variable i at the time of compilation which is constant so that compiler can use the compile time constant value(i=3) in other expressions for calculations at compile time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic