Pleiades All in One Eclipse 2020-03 has been released. Try out the new features for the migration from the current Java 11 LTS to the 2021 Java 17 LTS. Java Full Edition of Pleiades All in One is just unzipped, there is no need to install Java or set environment variables, and various settings of Eclipse are automatically done, so you can immediately use Java 14 with Japaneseized Eclipse. I will.
** Pleiades All in One Download ** http://mergedoc.osdn.jp/
Simply select 14 of the Java 6, 7, 8, 11, 14 configured by default. No Java download or installation path setting is required.
If you want to use the non-standard preview feature, set the project properties. Project> Right Click> Properties
This is a function that has been around for a long time, but if you just paste the Java source code text directly under src in the tree of Package Explorer instead of a file, the following behavior will be easy. You don't need to right click New> Class> Dialog.
Sample code for switches, records, text blocks, and pattern matching. It is in one class so that it is easy to paste and try.
import static java.lang.System.*;
import java.time.Month;
class Demo {
public static void main(String[] args) {
//--------------------------------------------------
// switch (Java 14 standard)
{
//Multiple labels-result: "Hello\nWorld\n"
var i = 1;
switch (i) {
case 0, 1, 2: out.println("Hello");
default : out.println("World");
}
}
{
//Arrow-result: Hello
var i = 2;
switch (i) {
case 2 -> out.println("Hello");
default -> out.println("World");
}
}
{
//switch expression-result:Big moon
var month = Month.MARCH;
String day = switch(month) {
case APRIL, FEBRUARY, JUNE, NOVEMBER, SEPTEMBER -> "Small moon";
case AUGUST, DECEMBER, JANUARY, JULY, MARCH, MAY, OCTOBER -> "Big moon";
};
out.println(day);
}
//--------------------------------------------------
//record (Java 14 preview)
{
//Inner record definition
record Point(int x, int y) {}
//getter automatic generation-result: 10
out.println(new Point(10, 20).x());
//toString automatic generation-result: Point[x=10, y=20]
out.println(new Point(10, 20));
//equals automatic generation-result: true
out.println(new Point(10, 20).equals(new Point(10, 20)));
}
//--------------------------------------------------
//Text block (Java 14 second preview)
{
//result: "Hello\n World"
String s = """
Hello
World
""";
System.out.println(s);
}
//--------------------------------------------------
//instanceof pattern matching (Java 14 preview)
{
//Assign with instanceof-result: 3
Object object = 1;
if (object instanceof Integer i) {
out.println(i + 2);
}
//Type and value compound condition
if (object instanceof Integer i && i == 1) {
out.println(i);
}
}
//--------------------------------------------------
//NullPointerException detailed output (Java 14 standard)
//In the VM argument of the execution configuration-XX:+Added ShowCodeDetailsInExceptionMessages
//result:
/*
Exception in thread "main" java.lang.NullPointerException:
Cannot invoke "String.length()" because "s" is null
at Demo.main(Demo.java:78)
*/
{
String s = null;
s.length();
}
}
}
Recommended Posts