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

前端 未结 5 1705
挽巷
挽巷 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条回答
  •  -上瘾入骨i
    2021-01-20 00:05

    Collections or arrays would be my preference. Making changes or adding additional fields would be easy. In your first example, you could do everything in one loop. You don't need a separate loop per attribute. Your code would be tiny after removing the extra loops.

提交回复
热议问题