java - Set a variable and print it, without any threads, but it prints the old value? -


i have simple piece of java code:

class {     static {         int x=3;         int y‭;         int yy=1234;         int yyy‮;y‭=1;int z‮y=x;         system.out.println("x: "+x);     } } 

i'd expect print "x: 1234".

javac a.java && java x: 3 exception in thread "main" java.lang.nosuchmethoderror: main 

but instead prints "x: 3". why? type of optimization don't know volatile? thought volatile matters if have multiple threads? tried setting variables volatile, , putting locks around them, no luck. told me should set strictfp on class, no luck there either.

you have characters make displaying weird. actual code:

  1 class {                                                                                                                  2     static {                                                                                                               3         int x=3;                                                                                                           4         int y<202d>;                                                                                                       5         int yy=1234;                                                                                                       6         int yyy<202e>;y<202d>=1;int z<202e>y=x;                                                                            7         system.out.println("x: "+x);                                                                                       8     }                                                                                                                      9 }             

<202e> called "right-to-left override"
<202d> "left-to-right override"


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -