0

Getter setter and array of object in java.

I want some good content about getter setter and array of object in java and is it possible array passing using getter or setter. Please send any content you can any link any code any description.

10th Jul 2019, 4:48 PM
VIJAY MOURYA
VIJAY MOURYA - avatar
2 Antworten
+ 1
I was about to write sure you can. But now I have some doubts to just write how you could do it because if you really mean an Object[] this will lead to 'problems' like reflections and should be avoided. Also you need to handle that arrays are static, in this context meaning: fixed size. I tend to recommend to use a List implementation whenever you need to deal with the limitations of an array. So, here's my advice: public void addToList(MyElement e) { this.myList.add(e); } public List<MyElement> getList() { return this.myList; }
10th Jul 2019, 8:36 PM
Tashi N
Tashi N - avatar
11th Jul 2019, 10:04 AM
zemiak