This file contains 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
fun trueOrFalse() = Random().nextBoolean() |
This file contains 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 Overloader { | |
public static void main(String[] args) { | |
Overloader o = new Overloader(); | |
o.testWithoutPrint(2); | |
o.test(2); | |
} | |
public void test(int a, boolean printToConsole) { | |
if (printToConsole) System.out.println("int a: " + a); | |
} |
This file contains 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
fun test(a: Int, printToConsole: Boolean = true) { | |
if (printToConsole) println("int a: " + a) | |
} | |
fun testWithoutPrint(a: Int) = test(a, false) | |
fun main(args: Array) { | |
testWithoutPrint(2) | |
test(2) | |
} |
This file contains 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 Turtle { | |
fun penDown() | |
fun penUp() | |
fun turn(degrees: Double) | |
fun forward(pixels: Double) | |
} | |
with(Turtle()) { | |
penDown() | |
for(i in 1..4) { | |
forward(100.0) |
This file contains 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
List list = people.stream().map(Person::getName).collect(Collectors.toList()); |
This file contains 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
val list = people.map { it.name } |
This file contains 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
int total = employees.stream() | |
.collect(Collectors.summingInt(Employee::getSalary))); |
This file contains 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
val total = employees.sumBy { it.salary } |
This file contains 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 SingleExpFun { | |
private BooleanSupplier trueOrFalse = new Random()::nextBoolean; | |
private boolean getNext(){ | |
return trueOrFalse.getAsBoolean(); | |
} | |
} |
This file contains 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
buildscript { | |
ext.kotlin_version = '1.1.60' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
} | |
} |