wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes how the execution happens? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how the execution happens?" Watch "how the execution happens?" New topic
Author

how the execution happens?

Ravindranath Chowdary
Ranch Hand

Joined: Nov 08, 2006
Posts: 71
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

I didn't dig deep into this, but it's probably because of a compiler optimization: the variables S in class V and I in class X are compile-time constants, so in your main() method the compiler replaces "V.S" and "X.I" by the values of the constants - and so classes X and V don't need to be loaded anymore.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think that's what Tony was hinting in another post. That bothers me though. What if a third party changes the value of V.S and I plug in a new jar but don't recompile? I'll miss the change?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Originally posted by Stan James:
I'll miss the change?


Yep. Therefore changing the value of a public static final field is not something to take lightly.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how the execution happens?
 
Similar Threads
Declare and use interface
When a final is not a constant
Super and sub class
HELP~~
Random string generation