Page List

Search on the blog

2011年1月29日土曜日

Code Name "Tiger"

Oops, seems I'm completely ignorant.
I didn't know JAVA's new features adopted in J2SE5.0 -- auto-boxing--.

This new feature introduced in "Tiger", which is the code name for J2SE5.0, is quite amazing.
Truth be told, I was under the impression that wrapping primitive types to Wrapper types was the biggest fault in JAVA.
But the drawback was removed so long ago, it seems.

Haha, what a pity.
It's just my luck, when I was using JAVA at work, the version was "Kestrel."

Here, I'll post the code utilizing the feature "auto-boxing" along with the feature introduced in Tiger, the "for-each" iterator.


public class Main {
public static void main(String args[]) {
ArrayList<Integer> x = new ArrayList<Integer>();

x.add(1);
x.add(100);
int n = 2;
x.add(n);

for (int i : x)
System.out.println(i);
}
}

Now that I learned JAVA's new selling points, I'm getting willing to switch to JAVA more than ever~~.


0 件のコメント:

コメントを投稿