Venkata Rahul

Greenhorn
+ Follow
since Dec 02, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Venkata Rahul

How can I debug an Oracle procedure when the procedure is fired from a JDBC call? I am using weblogic 9..

Regards
Rahul
This is what I observe:

Outside of any methods in your class, there are two blocks. One labeled static and other unlabeled as anything. The unlabeled block is executed every time an object of this class is made. The static block is executed every time the class itself is invoked. In your program, the static block is invoked twice (when the program is first run and then when the initialization takes place every time).

I think this is how it is going:

1. When the class is being fired initially, the variable is getting initialized to 1 initially and then being set to 2 thru the static block.

2. At the time of instantiation again, the static block is first run and consequently the value is going to 4.

3. The final nail in the coffin is with the unlabeled block which literally acts like a constructor (terming it an initializer block is more appropriate) setting the value to 4*2 which is 8.

Good doubt this.. It makes one think..

By the way, were you deliberate in using a common variable name in several place?

Best Regards
Rahul :roll: