• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is "compile-time constant"?

 
Woo Hwang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading "Getting in touch with your Inner Class" article, I encounter a term reading a paragraph blow:
Another warning about all inner classed is that that can't declare ant static members unless they are compile-time constant and are promitives or Strings( This does not apply to static nested classed, of course)
I don't know what is compile-time constant. Can anybody tell me what it is?
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Woo,
Any variable defined as final is considered to be a compile-time constant. The compiler will actually place its code in-line wherever it is used.

Regards,
Manfred.
 
Woo Hwang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply. Now I understand that. But I don't know what is like "place its code in-line" . Sorry, Engllish is not my native one.
Thank you
Woo
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think of it as a macro.
The compiler will convert MEMBER_VAR to 14. So when the code is executed you don't have a variable, you have a value (for MEMBER_VAR).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic