Created
June 6, 2018 02:12
-
-
Save systemhalted/e46ff1c0ae495d5cd87529aa1fc6e6de to your computer and use it in GitHub Desktop.
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
val array = Array(5) {it * 2} | |
println(array.asList()) | |
[0, 2, 4, 6, 8] | |
import kotlin.math.pow | |
val array = Array(7) { 1000.0.pow(it)} | |
val sizes = arrayOf("byte", "kilobyte", "megabyte", "gigabyte", | |
"terabyte", "petabyte", "exabyte") | |
for ((i, value) in array.withIndex()) { | |
println("1 ${sizes[i]} = ${value.toLong()} bytes") | |
} | |
1 byte = 1 bytes1 kilobyte = 1000 bytes1 megabyte = 1000000 bytes1 gigabyte = 1000000000 bytes1 terabyte = 1000000000000 bytes1 petabyte = 1000000000000000 bytes1 exabyte = 1000000000000000000 bytes | |
var arrayNum : MutableList<Int>?= null | |
for(i in 11..15) arrayNum?.add(i) | |
print(arrayNum) | |
null | |
var arrayNum : MutableList<Int?> = mutableListOf(null) | |
for(i in 11..15) arrayNum.add(i) | |
print(arrayNum) | |
[null, 11, 12, 13, 14, 15] | |
var arrayNum : MutableList<Int?> = mutableListOf() | |
for(i in 11..15) arrayNum.add(i) | |
print(arrayNum) | |
[11, 12, 13, 14, 15] | |
var numDivisibleBy7 : MutableList<Int> = mutableListOf() | |
for(i in 0..100 step 7) numDivisibleBy7.add(i) | |
print(numDivisibleBy7) | |
[0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment