How do I shuffle two arrays in same order in java

前端 未结 6 785
温柔的废话
温柔的废话 2021-01-12 01:40

I\'ve got two arrays of question and answers

String questions[] = {
\"Q1?\",
\"Q2?\",
\"Q3?\"};

String answers[] = {
    \"A1?\",
    \"A2?\",
    \"A3?\"}         


        
6条回答
  •  别那么骄傲
    2021-01-12 02:16

    Instead of shuffling answers and questions, you may shuffle an extra array of integers that has indexes to questions/answers and then extract question and answers from corresponding arrays using shuffled indexes.

提交回复
热议问题