Why does the first gender print out null?

topic description

Why does the first gender print out null

sources of topics and their own ideas

I"ve tried val gender: String = "male" , but the results don"t seem to be right.

related codes

constructor
zhu
null
derived constructor
zhu
zz
female
Apr.27,2021

there is a book suitable for this type of pit: " Scala Puzzle "

Chapter 4 inherits
the following rules control the initialization and overloading behavior of val :
1. Superclasses are initialized before subclasses;
2. Members are initialized in the declared order;
3. When a val is overloaded, it can be initialized only once;
4. Similar to abstract val , overloaded val has a default initial value during superclass construction.

also says that you can use lazy val , but lazy val also has some disadvantages:

1. Due to the occurrence of Synchronize at the bottom, this will incur a slight performance cost;
2. The abstract lazy val cannot be declared;
3. Using lazy val is easy to generate circular references, resulting in stack overflow errors and even deadlocks on the first visit.
4. Deadlocks can occur if a declaration is made between objects and the circular dependency between lazy val does not exist, which may be very subtle and imperceptible.

in addition, there are two other methods, one is to change val to def , and the other is to preinitialize the field, as follows:

  WHY IS MY ABSTRACT OR OVERRIDDEN VAL NULL?  

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7c138e-13b5f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7c138e-13b5f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?