#Getting data from excel list and assign it to data members of object

23 messages · Page 1 of 1 (latest)

hushed trellis
#

2d array?

errant zephyr
#

do you mind elaborating a little bit?

#

right now I have this?

#

or rather this was my approach

hushed trellis
#

here are some errors in it

errant zephyr
#

a for loop starting from a specific row and going through all its columns

hushed trellis
#

do u know what is array

errant zephyr
#

yeah

hushed trellis
#

we can make it 2d too

#

and more dimensional too

#

like int[] will be 1 d int[][] will be 2d

#

so an array inside an array

errant zephyr
#

okok

hushed trellis
#

there are some errors but in the code

#

like u didnt put a variable name for first field

#

e inventory<>

#

the

errant zephyr
#

oh yeah that ik

hushed trellis
#

u can initiitate array normally like
int[] array = new int[100];
int[][] array = new int[100][20];

abstract heath
#

So you're iterating through the rows and columns which is okay, but you need to collect all the columns at once instead of looping through them. So the i loop is okay but the j loop might need to be conveyed into eight calls of getCell(2) through to (9)

#

That way you'll have all the values in one place and can create an object

#

Actually, you can also keep the loop and keep track of what j is so you assign the value to the right member. say if I==2, set desc, j==3, set bin etc