Do all class constructors have to be public? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
- 1

Do all class constructors have to be public?

Does private constructors work the same way as public ones?

24th Jun 2016, 1:40 PM
Rishi Menon
4 Réponses
0
No, they can be private as well. In fact, any access modifier may be used, however there are specific times you'd want to use one access modifier over another.
24th Jun 2016, 5:05 PM
Drew Ski
Drew Ski - avatar
- 1
@Drew Ski Oh ok. I wonder why this isn't mentioned in this app. Anyway thx for replying so fast :D
25th Jun 2016, 1:38 PM
Rishi Menon
- 1
Actually, if you look in the More on Classes lesson, it is mentioned that they can be static and it is expanded on.
27th Jun 2016, 4:57 PM
Drew Ski
Drew Ski - avatar
- 1
@Drew Ski Oh ill check it out. : )
27th Jun 2016, 5:16 PM
Rishi Menon