Why use parallel arrays in Java?

前端 未结 4 1868
耶瑟儿~
耶瑟儿~ 2021-01-12 23:57

Is there any real use case for parallel arrays in Java? It seems too cumbersome to maintain N arrays which are interrelated.

Example:

int  ages[]   =         


        
4条回答
  •  广开言路
    2021-01-13 00:23

    Parallel arrays are a holdover from languages like Basic (the original one) that had no data structures other than arrays. You should define objects as you suggest, instead.

提交回复
热议问题