sorted¶
If elements in a List implements the Comparable interface,
you can call the method sorted
to return a sorted List (in nature order).
Note: Pair in Kotin does not implement the Comparable interface!!!
Returns and Jumps in Kotlin
Break at label is a convenient way to jump out of a nested loop.
Arrays in Java
Comments¶
- An array in Java is not an
Iterable
(due to design reasons). There is no super class of array andIterable
either in Java. If you want a method to support both array andIterable
as the parameter, you need to overload it (for both array andIterable
.) It is the same situation in Kotlin as Kotlin is mostly Java.
Example of Using Reflection in Java
Kotlin Unit Testing
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Use Java reflection to help test private methods.
https://phauer.com/2018/best-practices-unit-testing-kotlin/
https://medium.com/mindorks/how-to-unit-test-private-methods-in-java-and-kotlin-d3cae49dccd
Java Unit Testing
Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
import static org.junit.Assert.*;
assertEquals
assertArrayEquals
Use reflection to test private methods.
References
https://javarevisited.blogspot.com/2018/09/junit-testing-tips-constructor-is-called-before-test-methods.html
https://medium.com/mindorks/how-to-unit-test-private-methods-in-java-and-kotlin-d3cae49dccd