![]() Home | ![]() Back | ![]() Contents | ![]() Next |
setStrictJava(true); int a = 5; foo=42; // Error! Undeclared variable 'foo'. bar() { .. } // Error! No declared return type. |
// A common BeanShell "gotcha"! incrementX() { x = x + 1; // Really a local assignment } x = 5; incrementX(); print( x ); // 5! |
incrementX() { super.x = x + 1; // refer to parent scope explicitly } |
// Strict Java Mode setStrictJava(true); void incrementX() { x = x + 1; } int x = 5; // Must declare variables before use incrementX(); System.out.println( x ); // 6! |
Note: Strict Java Mode is relatively new. In the above example we switched to using System.out.println() instead of print() because the print() command and most other BeanShell commands have not yet been re-written to acomodate strict Java mode. |
![]() Home | ![]() Back | ![]() Contents | ![]() Next |