Lesson 26 of 34
Constructors மற்றும் thisConstructors and this
9 min 30 XP
Constructor என்பது class-ன் பெயரிலேயே உள்ள சிறப்பு method, return type இல்லை. new செய்யும்போது தானாக இயங்கும். this.name என்பது object-ன் field, name என்பது parameter.
A constructor is a special method with the class's name and no return type. It runs automatically on new. this.name means the object's field; plain name is the parameter.
Example: edit me and press Run
Press Run to see the result here.toString()-ஐ override செய்தால் System.out.println(object) அழகான text-ஐக் காட்டும்.
Override toString() and System.out.println(object) prints something readable instead of Book@1b6d3586.