I want to store an array of 100 int elements in rows ie 1 row of 100 int datatypes.And every single element contains an array of 100 objects.How to do this in java or android.
4 Answers
Use a collection, a "List of List":
List<List<YourType>> matrix2D = new ArrayList<List<YourType>>();
This structure can easily store a table with 200 rows and 100 columns where each element is of type YourType.
Otherwise - if your size is fixed and you just want to store YourType values, theres no need for generics:
int rows = 200;
int columns = 200;
YourType[][] matrix2D = new YourType[rows][columns];
Comments
Here is how you can initialize and fill a two-dimensional Object array:
Object value = 42;
int rows = 100;
int columns = 100;
Object[][] myData = new Object[rows][columns];
for (int r = 0; r < rows; r++) {
for (int c = 0; c < columns; c++) {
myData[r][c] = value;
}
}
Note that the primitive int value 42 is autoboxed when it is stored in the Object[][]. If you don't want this you could use an int[][] instead.
int. On the other hand, you say that each element contains an array of 100 objects. It is impossible for anintto contain anything. Please try to express yourself more clearly.