Archive for January, 2009

Varargs in Java

January 28, 2009 1 comment

I have recently asked most of my fellow coders the following question.

What is the output of this java program?

public class TestClient {
public static void main(String… args) {

All of the answers were “Compile time error”. Needless to say, I have introduced varargs to them.

Here is another question, how do you create a list which has 5 pre-defined element in it.

List<Integer> listIntegers = new LinkedList<Integer>();

But it is simple with varargs.

List<Integer> ids2 = Arrays.asList(1, 2, 3, 4);

was it cool!!? it is cool if we don’t know Ruby or Lisp.


January 13, 2009 Leave a comment

Executing single line of Java code – One Liner in Java.

Use eclipse scrapbook –

Another tip for Java-Eclipse :: type “instanceof¬† ctrl+space” for generate code from code-snippet.

Though both are old, I explored it just now

Categories: Uncategorized