This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum class Cheese{Light, Normal, Extra;} | |
| enum class Sauce{Marinara, GarlicParmesan, Alfredo} | |
| interface Topping | |
| enum class Veg: Topping {Onion, Tomato, Pepper, Spinach;} | |
| enum class Meat: Topping {Chicken, Pepperoni;} | |
| fun main() = | |
| pizza { | |
| large { | |
| add(Sauce.Alfredo) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.Instant; | |
| import java.time.LocalDate; | |
| import java.time.ZoneId; | |
| import java.util.Random; | |
| interface Generator<T> { | |
| T generate(); | |
| static Generator<Boolean> generateBoolean(){ | |
| return new Generator<>() { | |
| Random random = new Random(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.time.ZoneId; | |
| import java.time.ZonedDateTime; | |
| import java.time.format.DateTimeFormatter; | |
| import java.util.stream.Stream; | |
| public class WorldClock { | |
| public static void main(String[] args) { | |
| DateTimeFormatter FORMAT = DateTimeFormatter.ofPattern("E, dd MMM u hh:mm:ss a z"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class DesktopUtility { | |
| public static void main(String[] args) throws URISyntaxException, IOException { | |
| Desktop desktop = java.awt.Desktop.getDesktop(); | |
| if(!Desktop.isDesktopSupported()) | |
| return; | |
| // Opens composing window of default mail client | |
| desktop.mail(new URI("mailto:<email address>")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import j2html.tags.DomContent; | |
| import org.eclipse.jetty.server.Server; | |
| import org.eclipse.jetty.servlet.ServletContextHandler; | |
| import org.eclipse.jetty.servlet.ServletHolder; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.http.HttpServlet; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; | |
| import java.io.IOException; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Observable<Integer> observable = Observable.create(observableEmitter -> { // <1> | |
| System.out.println("Generating numbers"); | |
| new Random().ints(10, 0, 5) // <2> | |
| .forEach(i -> { | |
| delay(500); // <3> | |
| observableEmitter.onNext(i); // <4> | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Employee{ | |
| private Integer id; | |
| private String name; | |
| private Integer age; | |
| Employee(Integer id, String name, Integer age) { | |
| this.id = id; | |
| this.name = name; | |
| this.age = age; | |
| } |