Skip to content

Instantly share code, notes, and snippets.

View mcupak's full-sized avatar

Miro Cupak mcupak

View GitHub Profile
interface MyInterface {
void abstractMethod();
default void defaultMethod() {
System.out.println("default method called");
}
}
void readFile(String file) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
try (BufferedReader reader2 = reader) {
String line;
while ((line = reader2.readLine()) != null) {
System.out.println(line);
}
}
}
@mcupak
mcupak / geecon.jsh
Created May 11, 2018 08:19
Session notes from the Clean code with Java 9 talk at Geecon Krakow 2018.
1+1
int x = 1+1
System.out.println(x)
Thread.sleep(2000)
/vars
/types
/list
/l
/help
Set<String> set = new HashSet<String>()
@mcupak
mcupak / jwtb.jsh
Created April 24, 2018 21:04
Session notes from the Exploring Java 9 with REPL talk at Java With The Best 2018.
/
1+1
int x = 1+1
System.out.println(x)
Thread.sleep(2000)
/vars
/types
int inc(int x) { return x+1; }
inc(5)
/list
@mcupak
mcupak / indexconf.jsh
Created February 24, 2018 05:48
Session notes from the Exploring Java 9 with REPL talk at Index San Francisco 2018.
1+1
int x = 1+1
System.out.println(x)
Thread.sleep(2000)
/vars
/types
/list
/l
/help
Set<String> set = new HashSet<String>()
@mcupak
mcupak / singajug.jsh
Created January 5, 2018 06:41
Session notes from the Java 9, Episode 2 talk at Singapore Java User Group.
1+1
int x = 1+1
System.out.println(x)
Thread.sleep(2000)
/vars
/types
/list
/l
/help
Set<String> set = new HashSet<String>()
jshell> Optional.of("something").stream().forEach(System.out::println)
something
jshell> Optional.empty().stream().forEach(System.out::println)
jshell> Optional.of("something").or(() -> Optional.of("empty"))
$9 ==> Optional[something]
jshell> Optional.empty().or(() -> Optional.of("empty"))
$10 ==> Optional[empty]
jshell> Optional.of("something").orElseGet(() -> "empty")
$7 ==> "something"
jshell> Optional.empty().orElseGet(() -> "empty")
$8 ==> "empty"
jshell> Optional.of("something").orElse("empty")
$5 ==> "something"
jshell> Optional.empty().orElse("empty")
$6 ==> "empty"