如何可以洗牌下面陣列如何洗牌字符串數組
String[] firstName =["a","b","c","d","e"];
String[] lastName =["p","q","r","s","t"];
String[] salary =["10","20","30","40",50"];
String[] phoneNo= ["1","2","3","4","5"];
洗牌陣列我需要導致像
String[] firstName =["d","b","e","c","a"];
String[] lastName =["s","q","t","r","p"];
String[] salary =["40","20","50","30",10"];
String[] phoneNo= ["4","2","5","3","1"];
後意味着,例如,如果從firstName
變化"a"
指數從0至4 ,相應指數爲"p"
,"10"
,"1"
將從0改爲4 ..
@Sabik JavaScript不是Java。 – MikeCAT
你是從某個東西開始還是希望有人會將你的代碼轉儲? –
完成此操作的最佳方法之一是使用這4個字符串字段創建自定義對象。然後你可以有一個構造函數,比如'MyObject(String fN,String lN,String sal,String pN)'並用它來設置初始值。然後創建一個'MyObject'數組 –