two-dimensional arrays in Java -
just quick question - if instantiate new 2 dimensional int array so
int[][] input = new int[101][]; //number irrelevant eclipse seems not mind this, i'm not entirely sure if work i'm expecting to, second part of array act dynamically.
after reading answers, realise question badly worded.
i reading in file - csv , there 101 columns , x amount of rows. since reading file in line-by-line, simple me figure out first dimension of "2-d array" 101. but, because reading file line-by-line, cannot second dimension x without iterating through entire file.
how find x using current method, or impossible?
then you'd have 101 elements in input null. create second dimension, you'd need initialize every item:
input[13] = new int[63]; input[14] = new int[128]; the second dimension doesn't need same first level items. second dimension would same if used this:
int[][] input = new int[101][50]; all values initialized 0.
but real answer is: why didn't try?
Comments
Post a Comment