Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 3
Why constructor name same as class name
5 Respostas
+ 12
Constructor creates an instance of class. The names are same so that it can be unambigously identified as theĀ constructor. and how its get invoked implicitly when we create object of thatĀ class. It is invoked by the compiler because it has already been unambiguously identified because of its naming sheme.
+ 6
If it wouldn't be like this it would be interpreted like method
+ 4
To avoid ambiguity.
+ 1
There is no reason. It's just what the inventors decided. In other languages it's different. See the Ruby course for example.