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.util.concurrent.TimeUnit | |
| import kotlin.random.Random | |
| import kotlin.system.measureNanoTime | |
| fun main(args: Array<String>) { | |
| val names:List<String?> = listOf("Donn","John","Mike",null,"Davita","Jen",null,"Mihta") | |
| val namesThatareNotNull = names.filterNotNull() | |
| println(namesThatareNotNull) | |
| } |
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.util.concurrent.TimeUnit | |
| import kotlin.random.Random | |
| import kotlin.system.measureNanoTime | |
| fun main(args: Array<String>) { | |
| measure { | |
| val list: Sequence<Int> = generateSequence(Random.nextInt(0,100)) { Random.nextInt(0,100) } | |
| .take(100_000_000) |
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.util.concurrent.TimeUnit | |
| import kotlin.random.Random | |
| import kotlin.system.measureNanoTime | |
| fun main(args: Array<String>) { | |
| measure { | |
| val list: List<Int> = generateSequence(Random.nextInt(0,100)) { Random.nextInt(0,100) } | |
| .take(100_000_000) |
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
| fun main(args: Array<String>) { | |
| val states:MutableMap<String, String> = mutableMapOf( | |
| "NY" to "New York", | |
| "NJ" to "New Jersy", | |
| "CA" to "California" | |
| ) | |
| var result: String?=states.get("NY") | |
| println(result) |
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
| fun main(args: Array<String>) { | |
| val i=9 | |
| if (i in 0..10){ | |
| println("Yes") | |
| }else { | |
| println("No") | |
| } |
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
| fun main(args: Array<String>) { | |
| var people: List<Persons> = listOf( | |
| Persons("Michael"), | |
| Persons("David"), | |
| Persons("Mark"), | |
| Persons("Paul"), | |
| ) |
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
| fun main(args: Array<String>) { | |
| var people: List<Persons> = listOf( | |
| Persons("Michael"), | |
| Persons("David"), | |
| Persons("Mark"), | |
| Persons("Paul"), | |
| ) |
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
| fun main(args: Array<String>) { | |
| var people: List<Persons> = listOf( | |
| Persons("Michael"), | |
| Persons("David"), | |
| Persons("Mark"), | |
| Persons("Paul"), | |
| ) |
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
| fun main(args: Array<String>) { | |
| val values: List<Int> = listOf(1, 2, 3, 4, 5, 6, 7, 8) | |
| for (number in values) { | |
| println(number) | |
| } | |
| for (i in 0 until 100) { | |
| println(i) |
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
| fun main(args: Array<String>) { | |
| val names:MutableSet<String> = mutableSetOf("Donn","John","Felicia") | |
| println(names) | |
| names.add("Michael") | |
| println(names) | |
| names.remove("John") | |
| println(names) | |
| val people:Set<Person> = setOf( |