Lesson 26 of 34
Constructors ಮತ್ತು this
9 min 30 XP
Constructor ಎಂದರೆ class ನ ಹೆಸರಿನ, return type ಇಲ್ಲದ ವಿಶೇಷ method. ಅದು new ನಲ್ಲಿ ತಾನಾಗಿಯೇ ಓಡುತ್ತದೆ. this.name ಎಂದರೆ object ನ field; ಕೇವಲ name ಎಂದರೆ parameter.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.toString() ಅನ್ನು override ಮಾಡಿದರೆ System.out.println(object) Book@1b6d3586 ಬದಲು ಓದಬಹುದಾದದ್ದನ್ನು print ಮಾಡುತ್ತದೆ.