• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with two dimensional arrays  RSS feed

 
Tiberius Marius
Ranch Hand
Posts: 115
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the program bellow that grades students(based on a two dimensional array with the answers) and i need to make it display the students based on the grades/scores in ascending order . I did that in two ways (using a array and a two dimensional array) but i have a hunch it can be done much more simple then i did it (but still using array object and nothing else ) . Any input about how to solve the problem in a more easy way is appreciated !



My first solution creating an array with the grades for sorting :




My second solution using a two dimensional array :


 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I only see one-dimensional arrays here. That's because Java only supports one-dimensional arrays, but they can hold...arrays.

In other words, you have an array that holds a bunch of character arrays.
 
Tiberius Marius
Ranch Hand
Posts: 115
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well , in the book that i m learning Java from i have a whole chapter called Multidimensional Arrays.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In which case the book is wrong, or at least misleading.
Start by writing yourself a utility class for arrays. I'll give you a start. Private constructor because you never need any instances of it. All methods static.Always use the methods of that class; never put sorting logic in other methods. If the methods you have already work you can simply copy them into the utility class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!