Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Java12/Examples"
Line 33: | Line 33: | ||
<br> | <br> | ||
[[File:j12.compliance.png]] | [[File:j12.compliance.png]] | ||
− | |12 is shown in the drop down list | + | |12 is shown in the drop down list. |
+ | A checkbox to enable preview features is available on the preference page. | ||
|- | |- | ||
| No compiler errors | | No compiler errors | ||
Line 63: | Line 64: | ||
<br> | <br> | ||
<br> | <br> | ||
− | [[File: | + | [[File:switch-exp.compile.png]] |
| Code compiles | | Code compiles | ||
+ | |- | ||
+ | ! scope="row" | Compiler Warning Cases | ||
+ | | | ||
+ | <source lang="java"> | ||
+ | package j12.preview; | ||
+ | |||
+ | public class Test { | ||
+ | |||
+ | enum Day { | ||
+ | MON, TUE, WED, THUR, FRI, SAT, SUN | ||
+ | }; | ||
+ | |||
+ | public String getDay_1 (Day today) { | ||
+ | String day = switch(today) { | ||
+ | case MON, TUE, WED, THUR, FRI: break "Weekday"; | ||
+ | case SAT, SUN: break "Weekend"; | ||
+ | }; | ||
+ | return day; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | <br> | ||
+ | <br> | ||
+ | [[File:switch.preview.warning.compile.png]] | ||
+ | | Compiler warning is shown for preview feature | ||
|- | |- | ||
! scope="row" | Compiler Error Cases | ! scope="row" | Compiler Error Cases | ||
| | | | ||
<source lang="java"> | <source lang="java"> | ||
+ | package j12.preview; | ||
+ | public class Test { | ||
+ | |||
+ | enum Day { | ||
+ | MON, TUE, WED, THUR, FRI, SAT, SUN | ||
+ | }; | ||
+ | |||
+ | @SuppressWarnings("preview") | ||
+ | public String getDay_1 (Day today) { | ||
+ | String day = switch(today) { | ||
+ | case MON : break "Weekday"; | ||
+ | case SAT, SUN : break "Weekend"; | ||
+ | }; | ||
+ | return day; | ||
+ | } | ||
+ | } | ||
</source> | </source> | ||
− | | Compiler | + | <br> |
+ | <br> | ||
+ | [[File:switch.cover-all-cases.error.png]] | ||
+ | | Compiler error is shown | ||
|- | |- |
Revision as of 06:44, 18 March 2019
= NOTE: THE PAGE IS UNDER CONSTRUCTION
This is an informal page listing examples of features that are implemented by the Java 12 Support. You are welcome to try out these examples. If you find bugs, please file a bug after checking for a duplicate entry here