• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add numbers in a column in a multidimensional array, with the column being chosen by the user  RSS feed

 
Seth Lamb
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Right now my code gets all the numbers in a row and adds those up, but I want it to get the numbers in a column and add them instead. The problem is I don't know how to get the userpick (the number that the user picks to determine which column gets added) to be set to that particular column.
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Seth,

what about:

matrix[row1][userpick]? (look at lines 40-45)

Greetz,
Piet
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot:

since each row can contain an array of different length (not in your code given),
column 'userpick' may exist for some rows, but not for all rows. If you want to
have a general method, then you should check this.

Greetz,
Piet
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!