Java attributes | Sololearn: Learn to code for FREE!


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(); }

6/22/2020 6:27:16 PM

Mahmod El-Shambaky

2 Answers

New Answer


Since you tagged linked list, I assume you are trying to make one. This should be helpful in getting you started:


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