1.

What Are The Major Differences Between Scala’s Auxiliary Constructors And Java’s Constructors?

Answer»

Scala’s Auxiliary constructor is almost similar to Java’s constructor with few differences.

Compared to Java’s CONSTRUCTORS, Auxiliary constructors have the FOLLOWING few differences:

  • The auxiliary constructors are called using “this” keyword.
  • All auxiliary constructor are defined with the same name that is “this”. In Java, we USE class name to define constructors.
  • Each auxiliary constructor must start with a call to a previously defined auxiliary constructor or the primary constructor.
  • We use ‘DEF’ keyword to define auxiliary constructors like method/function definition. In Java, constructor definition and Method definition is different.

Scala’s Auxiliary constructor is almost similar to Java’s constructor with few differences.

Compared to Java’s constructors, Auxiliary constructors have the following few differences:



Discussion

No Comment Found