|
Although I am not a Java engineer, I never and did not intend to write Java, but still very concerned about this technology. Java 8 on the new features:
The interface has been completely static method can be defined. A common example is the java class library, for some interfaces, such as Foo, there will be a static method of the tool class to generate or Foo object instance to use. Static methods can exist in the interface, so in most cases Foos tool class can use the interface in the public method to proxy (or Foos into package-private).
In addition, the more important thing is, Java 8 interface can define the default method. For example, a for-each loop method can be added to the java.lang.Iterable:
Public default void forEach (Consumer < ? Super T> action) {
Objects.requireNonNull (action); for (T t: this) {
Action.accept (t);
}}
}}
In the past, adding a method to a Java class library interface is basically impossible. Adding a method to an interface means breaking code that implements that interface, but now, as long as it provides a correct and sensible default method implementation, Java class library maintainers can add methods in the interface.
Java 8, a lot of the default method has been added to the core of the JDK interface.
The following is the focus of this article, the use of PPA in Ubuntu install Java 8 (support Ubuntu 10.04 - Ubuntu 14.04):
Sudo add-apt-repository ppa: webupd8team / java
Sudo apt-get update
Sudo apt-get install Oracle-java8-installer
When finished, you can view the version with the following command:
Javac -version
Installation of Java 8 requires a license, and if you want to install it automatically, you can run it before installing:
Echo oracle-java8-installer shared / accepted-oracle-license-v1-1 select true | sudo / usr / bin / debconf-set-selections
Setting the Java 8 environment variable:
Sudo apt-get install oracle-java8-set-default
Switch to Java 7:
Sudo update-java-alternatives -s java-7-oracle
And then switch to Java 8:
Sudo update-java-alternatives -s java-8-oracle |
|
|
|