0

Unnecessary method change()?

Just to be clear, instead of calling the method change() which changes the value to ten, can't we just say p.setAge(10)?

9th Feb 2017, 11:48 PM
Sathvik Kuthuru
Sathvik Kuthuru - avatar
1 Resposta
+ 1
sure you can. but it's just a sample to teach you how to reuse functions (methods). the pro of modular programming is to be able to reuse repetitive functions without having to implement over and over.
10th Feb 2017, 3:05 AM
Mehrad Aria
Mehrad Aria - avatar