Nifty way to iterate over parallel arrays in Java using foreach

后端 未结 8 908
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 04:29

I\'ve inherited a bunch of code that makes extensive use of parallel arrays to store key/value pairs. It actually made sense to do it this way, but it\'s sort of awkward to

8条回答
  •  别那么骄傲
    2020-12-13 05:13

    Simple answer: No.

    You want sexy iteration and Java byte code? Check out Scala: Scala for loop over two lists simultaneously

    Disclaimer: This is indeed a "use another language" answer. Trust me, I wish Java had sexy parallel iteration, but no one started developing in Java because they want sexy code.

提交回复
热议问题