Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Comments¶
An array in Java is not an
Iterable(due to design reasons). There is no super class of array andIterableeither in Java. If you want a method to support both array andIterableas the parameter, you need to overload it (for both array andIterable.) It is the same situation in Kotlin as Kotlin is mostly Java.
Compare Arrays in Java¶
Instantiate Array Using Curly Braces¶
import java.util.Arrays;
long[] arr = new long[] {1, 2, 3};
Arrays.stream(arr).forEach(i -> System.out.println(i));1
2
3
nullCast Arrays¶
https://
https://
System.arraycopy¶
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);Arrays.copyOfArrayList to Array¶
ArrayList.toArray(new Type[0])Stream¶
String[] strings = Arrays.stream(objects).toArray(String[]::new);String[] strings = Arrays.stream(obj).map(Object::toString).toArray(String[]::new);