var a = arrayOf(1,2,3); print(a.contentToString()) print(a.max()) print(a.min()) a.reverse()
creating hashmap
1 2 3
var ah= newHashMap<>(); ah.put(1,2);
1 2
var ah = hashMapOf(1 to 2, 2 to 3)
iterate lists with indices
java double colon :: operator acts as anonymous function
1 2 3 4 5 6 7 8 9 10 11 12
varl= a.listIterator(); while (l.hasNext()){ varindex= l.nextIndex(); varval= l.next(); System.out.println("INDEX: "+index+" ELEM: "+val); } IntStream.range(0,a.size()).forEach(index -> a.get(index)); var index=0; for (int i: a){ index++; }
1 2 3 4 5 6 7 8 9
a.forEachIndexed{ind, elem -> println("index? $ind"); println("elem? $elem")} for (var i in a.indices){ var elem = a[i] } a.indices.forEach { var elem = a[it] elem }