Preskočiť na hlavný obsah

Java 8 / did U know?

JavaScript engine

Engine Nashorn replaces old one (Rhino) as the new default JavaScript engine for the Oracle jvm. Nashorn is faster. It uses the invokedynamic feature of the jvm. "jjs" is Nashorn command line tool.

Optional

8 comes with the Optional class (java.util.Optional) for avoiding nulls (NullPointerException). It is very similar to Google’s Optional, which is similar to Nat Pryce’s Maybe or Scala’s Option class.

Streams

What is a Stream? Stream is a interface (java.util.stream.Stream) and represents a sequence of some objects. However, unlike the Iterator, it supports parallel execution. The Stream supports the map/filter/reduce design pattern and executes lazily, forming the basis (along with lambdas) for functional-style programming in Java 8.


Example:
// finding a maximum
max = list.stream().reduce(0.0, Math::max);

Obľúbené príspevky z tohto blogu

mysql 5.0 upgrade to 5.1

The 5.1 series of MySQLwas unmasked for the gentoo portage. When upgrading from an older major version (including 5.0), you will be required to rebuild everything linked to the libmysqlclient.so.15 and libmysqlclient_r.so.15. You can do this by installing app-portage/gentoolkit and running: # revdep-rebuild --library libmysqlclient.so.15 # revdep-rebuild --library libmysqlclient_r.so.15 If you use the Portage 2.2 series, you may also use: # emerge @preserved-rebuild The official upgrade documentation is available here: http://dev.mysql.com/doc/refman/5.1/en/upgrading.html Note that existing databases may need converting as well, again including those upgrading from 5.0 to 5.1.