Archive for July, 2010
More fun with Java (scope and duplicates)
I thought this was interesting… In Java, a block scoped variable may conflict with a local variable declared later in method scope, but not previously (as shown below):
class A{ public static void main(String args[]){ {int k = 5;} int k = 12; //this is OK {int k = 22;}//this is not.... } }
This is not the same as C++ where this compiles happily:
int main(){ {int i;} int i; {int i;} return 0; }
Usually C++ has the more obscure behavior….
No commentsProtected within Java Enums
I just noticed that java enums allow protected member variables and methods. Why is this interesting? Can you think of any code that might actually make use of a protected member in an enum (as opposed to private)? Example after the jump (warning, not practical…).
Read more
SWIG, Java, and JRuby
Providing a robust, maintainable, and interactive interface to your C/C++ application can be a challenge, but I’ve found that a combination of SWIG, Java, and JRuby (or Jython if you prefer) makes for a very powerful combination.
Read more