Class level fields are initialized before anything else, which means that null is assigned. You can make a lazy val declaration and it will not be initialized until it is called. This is the reason def works. Best of all, instead of creating a private class field for a private constructor field, simply make the constructor field publicly available as follows:
class ArrayElement(val contnts: Array[String]) extends Element {}
Since there is a parent class, it would be nice to mark it as an override;
class ArrayElement(override val contnts: Array[String]) extends Element {}
If this is a stateless data container class, the best option is to make it a case class that (among several other things) has default fields.
case class ArrayElement(override val contnts: Array[String]) extends Element
This is a much more idiomatic scala, and it will provide you with equals , hashCode based on values, pattern matching, simpler construction (no new needed)
source share