Is it Better practice to Declare individual objects or loop Anonymous objects into ArrayList?

前端 未结 5 1746
挽巷
挽巷 2021-01-19 23:17

I am learning programming with Java through a textbook. A programming exercise asks you to:

(Swing common features) Display a frame that contains six labels. Set th

5条回答
  •  生来不讨喜
    2021-01-19 23:51

    It seems that you have answered the question yourself. Yes you would need references (what you call a variable name) if you there is a requirement to manipulate the labels (change attributes) on event generations. But yes if there is no such requirement, in that case your method of using an Array or List is clean and requires less code writing effort.

提交回复
热议问题