Why Lambda Expressions in Java

04 Apr 2013

Lambda expressions are coming to Java 8, but apparently they are still encountering some resistance and not all Java developers are convinced of their usefulness. In particular they say that it could be a mistake to try to add some functional features to Java, because they fear that this could compromise its strong object oriented and imperative nature. The purpose of this article is to hopefully remove any further doubt and show clearly, with practical and straightforward examples, why it is not possible for a modern programming language to not support lambda expressions.

Read more... lambda


Class Loaded and Initialized

04 Apr 2013

As we know .java file is first compiled to .class file at compile time. And we know Java can load a class at run time.

The confusion is what is the difference between 'load' and 'initialize'. When and how is a Java class loaded and initialized?

What does it mean by saying 'load a class' ?

Read more... class , java


New Features in JDK

04 Apr 2013

我最初学习 Java 的时候,公司的大多数应用,都是基于 JDK 1.4.2.14,因此我也是从这个版本入手。搜索 ArrayList 的教程,发现诸如泛型的代码,对其中的 < > 甚是不解,请教同事,才知道就是 JDK5 引进的新功能,泛型。当是时,JDK6 已经发布了。

但公司为了稳定起见,不会着急更新。直到现在,核心应用都是还是 JDK6。

后来专门花了不少精力学习 JDK5 的新特性,除了泛型,还有自动封装箱,增强 for 循环,极大的提高了生产效率,至今印象深刻。

六年过去了,Java 早已易主,而 JDK8 的发布也指日可待,这里重新整理一下 JDK5 以来,Java 主版本的新功能,不能总是过着刀耕火种,茹毛饮血的生活。

Read more... java , jdk


Java vs Python

04 Apr 2013

Some people have claimed that Python is more productive than Java. It is dangerous to make such a claim, because it may take several days to prove that throughly. From a high level view, Java is statically typed, which means all variable names have to be explicitly declared. In contrast, Python is dynamically typed, which means declaration is not required. There is a huge debate between dynamic typing and static typing in programming languages. This post does not talk about that. However, there is one thing that can be agreed – Python is an interpreted language with elegant syntax and that makes it a very good option for scripting and rapid application development in many areas.

Read more... java , python


HashSet vs TreeSet

04 Apr 2013

In a set, there are no duplicate elements. That is one of the major reasons to use a set. There are 3 commonly used implementations of Set in Java: HashSet, TreeSet and LinkedHashSet. When and which to use is an important question. In brief, if we want a fast set, we should use HashSet; if we need a sorted set, then TreeSet should be used; if we want a set that can be read by following its insertion order, LinkedHashSet should be used.

Read more... set , treeset



从小,就有许多梦想,现在,一个也不曾留下。我也没有了眼泪。

黑沉沉的夜里总是开满黑沉沉的花。慢慢睡去,月光撒落,这个世界干燥冰凉。