Archive for the 'Java' Category
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
Embedding Rhino Part I: Parsing Command Line Arguments in JavaScript
Rhino is a JavaScript/ECMAscript implementation in Java. Using the new java1.6 scripting API you can now easily embed JavaScript into your Java applications. I thought I’d try writing yet another implementation of the net_tool application using Rhino. Originally this was going to be a single article, but it turns out to be a two-fer.
Read more
Converting hex to Binary in Java Too
So apparently the hex to binary in 4 languages portion of this web page is what gets the most google hits and who am I to argue? So without further ado, hex to binary in Java as well…
No commentsJava’s @Override Annotation
Most people are aware of java annotations by now, but I’m not sure everyone knows about @Override. They really should.
No commentsUsing Javacc
If you want to parse a custom language in java then Javacc is your tool. At the moment this is probably more a reminder to myself than a great article for anyone else to read, but as you find it useful feel free to take a look. More after the link…
Read more
Why I Can’t use Maven
In my most recent development effort at work I decided to take a look at the new kid on the block for building java projects: Maven 2. After 6 months or so of use I’m now preparing to use ant instead. Details after the link.
Read more
Using Custom Symbols in CUP
CUP lists being able to use your own Symbol class as a big selling point of the latest version, but they don’t say much about how to do it. In addition there is actually a fairly annoying bug in the code. Of course you may ask “Why not use javacc?” Good question. Anyway, without further ado… Read more
No comments