fun main() {
val stack = java.util.Stack<Int>();
stack.push(null);
val arr = java.util.ArrayList<Int>();
arr.add(null);
}
IDEA underlines the null in the 5th line with a red wavy line and warns that Null can not be a value of a non-null type Int. But It ignore the null in the 3rd line.
And after deleting the fifth line, the program can run normally.
why in Kotlin, Stack can push(null) but ArrayList cannot add(null)?
Thanks.