parallel-arrays

How would I approach Parallel Arrays to store different types of information in java

旧街凉风 提交于 2020-06-17 08:03:51
问题 I have the following task which is that: There may be up to ten teams. Parallel Arrays are used to store the team Names, as well as to keep track of the number of Wins, Overtime Losses, and Points. After the result for the last team is entered, the program outputs a summary of each team's record in the opposite order to which they were entered. Note: "W" is worth 2 points, "L" is worth 0 points, "O" is worth 1 point Sample input: 3 //Option number Toronto //phrase W //letters that loop in a

Sort a parallel array using Arrays.sort()

那年仲夏 提交于 2019-12-17 07:54:51
问题 Is it possible to sort an array using Arrays.sort() and thereafter have another related array positioned the same as the sorted array for example: String arrNames[] = new String[5]; String arrCellNo[] = new String[arrNames.length]; String arrNamesSorted[] = new String[arrNames.length]; System.arraycopy(arrNames, 0, arrNamesSorted, 0, arrNames.length); Arrays.sort(arrNamesSorted); From this point what i would like to do is sort the CellNo array such that if "person" had a cellNo "x", he will

how to write a parallel array [duplicate]

南笙酒味 提交于 2019-12-11 14:49:21
问题 This question already has answers here : Sort a parallel array using Arrays.sort() (5 answers) Closed 5 years ago . hi everyone I'm just curious on how one would write a code for an array that will sort indexes in order to match a previous array's inputs. Example of what i mean: If array 1 had inputs in this order: 1,2,3,4 How the indexed variables would look in array 1 A[0] = 1 A[1] = 2 A[2] = 3 A[3] = 4 Then i ask a user to input a number from the previous array so they can add information

Why use parallel arrays in Java?

喜你入骨 提交于 2019-12-01 02:33:05
问题 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[] = {0, 17, 2, 52, 25}; String names[] = {"None", "Mike", "Billy", "Tom", "Stan"}; int parent[] = {0, 3, 1, 0, 3}; I can just create a class Person and store objects in one single array. Will be little more expensive, but much easy to use right? 回答1: Parallel arrays are a holdover from languages like Basic (the original one) that had no data structures