Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/g-khan/java9-examples
Java 9 features example
https://github.com/g-khan/java9-examples
Last synced: 8 days ago
JSON representation
Java 9 features example
- Host: GitHub
- URL: https://github.com/g-khan/java9-examples
- Owner: G-khan
- Created: 2020-09-01T04:28:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-01T04:31:02.000Z (about 4 years ago)
- Last Synced: 2023-07-19T17:34:39.098Z (over 1 year ago)
- Language: Java
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Java 9 Features Example
## Features:
- **Private Methods in Interface:** Encapsulation is possible in interface that mean you can avoid code duplication in default methods. Also private interface methods can be *static* or *instance*.
_see_: Magician class prepareForMagic method
- **Optional Class Improvements** _see_: Spectators class
- Optional.ifPresentOrElse()
- Optional.or()
- **Immutable Collection Factory** _see_: Spectators class
- `List names = List.of("Gokhan", "Ahmet", "Ayse");`
- Cannot set null item in to List.of: `java.lang.NullPointerException`
- Cannot add new item: `UnsupportedOperationException`
- `Set names = Set.of("Gokhan", "Ahmet", "Ayse");`
- Cannot set null item in to List.of: `java.lang.NullPointerException`
- Cannot add new item: `UnsupportedOperationException`
- Cannot add duplicate item: `IllegalArgumentException`
- `Map immutableMap = Map.of("Key1", "Gokhan", "Key2", "Ahmet");`
- Cannot put new key value pair: `UnsupportedOperationException`Example inspired by https://www.polidea.com/blog/Exploring-Java-9Private-Interface-Methods/