I place here lambda constructions which I use most often.
Category Archives: Java
Install Java8 on Ubuntu
Just a short memo how to install Java 8 on Ubuntu.
Install:
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
Check java version:
Install Java 8 JDT in Eclipse
http://wiki.eclipse.org/JDT/Eclipse_Java_8_Support_(BETA)
Does Java allow two classes in one file?
Short answer will be: no, it does not for public classes. But yes, it does for non-public ones.
According to JavaSE7 specification http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.6 it's up to compiler to allow or deny multiple public classes in one file:
If and only if packages are stored in a file system (§7.2), the host system may choose to enforce the restriction that it is a compile-time error if a type is not found in a file under a name composed of the type name plus an extension (such as .java
or .jav
) if either of the following is true:
In practise, all compilers I ever met applied this restriction. The rule is: one public class – one .java file (which is a compilation unit) with the same name.
For example, let's put two public classes in one file and we'll get compilation error: