0

Java attributes

Can i name an attribute by its class name .. for example if i have a class called Class Box{ Int data; Box next; <--- this is my point ! Box(); }

22nd Jun 2020, 6:27 PM
Mahmod El-Shambaky
Mahmod El-Shambaky - avatar
1 Resposta
+ 3
Mahmod El-Shambaky I don't think it is good to make a attributes of class itself because we already set and get data using setter and getter method of class. But we can make attributes of Class, attributes of ArrayList of class object, attributes of HashMap of class in other class and make setter, getter method and access the data. You can see this example https://code.sololearn.com/cLYhMf8l8jLp/?ref=app
22nd Jun 2020, 6:51 PM
A͢J
A͢J - avatar