Get the App
SLTechnology News&Howtos  ›  Servers  › 

Learn a little bit of Scala's class constructor every day

Shulou Source: shulou.com Published: 2022-06-03 00:49:13 11月17日 Update

The class constructors in An and scala are as follows:

Main constructor

Slave constructor

B, main constructor

Parameter list, written after the class name

Main constructor content: the content in the class, except for field definition and method definition, is the content of the main constructor.

C, slave constructor

Class, which begins with def this, is derived from the constructor

The first line of the slave constructor must call the master constructor, or other slave constructors; in fact, it is a restriction that the first line of the slave constructor must be the master constructor, which is the only entry point for the class.

Tags: Constructor content one line that is entry parameter field beginning method class name restriction Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi MySQL MariaDB macOS