Tag Archives: java

Robocode New Beta Release

Robocode Logo

Robocode Logo


Robocode has released a beta version for, I am happy to contribute 1 feature and 1 bug fix in this release. Please download, test it and tell us any bugs you found





Robocode in SourceForge

Anonymous class Java

Some days ago, when answering a question on stackoverflow , I just recognized that I didn’t understand much about anonymous class in Java. Maybe I am not the only one, so I post it here. I think this should be in some book already, but by my bad, I didn’t read it well.

Ok, here is a simple question on stackoverflow:

 public static void main(String[] args) {
          new myClass() {
             public String toString() {
               return "myInterfacetoString";

          new myClass() {
              public String myFunction() {
                return "myInterfacemyFunction";
and the user asked why the output is:

It is extremely easy, right? Because you override the method toString() of the Object class. But then, the questioner asked more: how about change from new myClass() –> new myInterface() with some interface myInterface already declared, what would happen?

My first thought is that the class name of the anonymous class is not necessary and having no relationship with the real class, interface sharing the same name

But I just remembered about some of my snippet code before with

      new Runnable(){
       public void run() {}

will behave well like a runnable object

So, what is a correct way of anonymous class. After asking Google, I found a good link about it:


There are 2 main important points:

new className(optional argument list){classBody}

This expression instantiates a new object from an unnamed and previously undefined class, which automatically extends the class named className, and which cannot explicitly implement any interfaces. The body of the new class is given by classBody.

The result of executing this expression is that a new class that extends className is defined, a new object of the new class is instantiated, and the expression is replaced by a reference to the new object.

new interfaceName(){classBody}

This expression instantiates a new object from an unnamed and previously undefined class, which automatically implements the interface named interfaceName, and automatically extends the class named Object. The class can explicitly implement one, and only one interface, and cannot extend any class other than Object. Once again, the body of the new class is given by classBody.

Online Programming and Software Development Competitions

In my university, it was hard to find chances to go for programming and software competitions (like ACM and Imagine Cup), part of the problem is my fault as well. So, I usually find and join online competitions. Anyway, it is not the main ideas of this post. I want to introduce programming competitions that other people can find fun.

For me, competitions are chances to be fun, to boost skills and to communicate with other people. Fun may be the most important thing, because if it is not fun, interesting and challenging, there is no reason to do it.

1. TopCoder : a lot of kinds of competitions here. This is my favourite one.

A short competition lasts about 1 hour to compete with other people in a 3-problem test with easy, normal and difficult level. You can also do code review, challenge others’ solutions by your own test cases. I love this idea because now, your solution is both validated as well as verified by other people.

It is fun and realistic for software developer. You can even earn money. The only problem is that time to compete is really short, about 2 or 3 days and require in-depth knowledge about J2EE and .NET. I did not have any time to try out with this competition

This is a NP-complete problem competition. You can only find the way to make it better, find the most optimal solution. There are many kinds of problems here: range from encryption, game strategy and image analysis. I love game strategy most. The drawback is you have to spend a lot of time but I think that’s worth and give you a lot of fun

Bug Race will be good for tester, joining, finding bugs. Studio is good for designers. That’s all I know because I never tried this

2. Sphere Online Judge (SPOJ): Pure-algorithm competitions

I think this site is good for beginner and for people who wants to boost algorithms skills and knowledge.  If you are an algorithm lover, this site will be fun; otherwise, it seems quite boring when discussion and sharing ideas are quite limited. People compete with each other to try to get a little bit faster in time to be in the top. That is the disadvantage of this site, people spend too much time for a little performance improve, which is usually not a good practice for a software developer to do so.


An algorithm competition, challenging. I tried only once in last year and then this year, I think that I am still not good enough for that. It is a 3-people team competition by solving really tough algorithm problems in 5 hours. If you win, you can go to compete onsite with a wide range of topics: Information Theory, AI, Game Theory, Networking…

4. RoboCode (I think in www.diendantinhoc.org somebody is also interested in)
I am currently doing research and trying with this one for the purpose of RMITC club. RMIT students will try to learn by doing in this challenge. I hope we can learn in many different technologies: Event-Driven, Multi-threading, Agent-Oriented, Game Strategy, Software Design… See the demo below.

For me, that game looks like another agent game that RMIT Melbourne teaches for the course Agent-Oriented Programming and Design