The two topics seen on the forum are as follows:
//why is the result 1 0 not 0 0 who can explain ? Public classFinallydemo {Static intValue = 0; Static intInc () {returnvalue++; } Static intDec () {returnvalue--; } Static intGetResult () {Try { returnInc (); } finally { returnDec (); } } Public Static voidMain (string[] args) {System.out.println (GetResult ()); System.out.println (value); } }
Public class Null { publicstaticvoid greet () { System.out.println ("Hello World "); Public Static void Main (string[] args) { null; X.greet (); ((Null) x). greet (); ((Null) NULL ). greet (); } } //
The first one needless to say, the test is the implementation of the suffix increment/decrement operator (incredibly unknown), finally.
Simply put, the statements in the try must be executed first, and finally the statements must be executed behind the try. The only thing that makes a mouthful is that if there is a return, then the return statement of the try is staged, and the return! in finally is executed.
However, finally once return, try: Catch.. Finally, it's over . --try's return was ignored ... 囧
Second, the first time to see, according to the reply to Daniel said it is possible to test the invokestatic directive? --JVM instructions.
This expression is powerless, can only remember the conclusion, the static method of the call, independent of the object, the underlying should be based on the type of object directly find the calling method !!!
Java about Finally, static