Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can you people please say how a for loop works in multi dimensional arrays? ex: matrix multiplication /sorting 2 string arays usin compareTo() method

user-image
Question ajoutée par ramaswami s
Date de publication: 2013/11/11
Daanish Rumani
par Daanish Rumani , Product Manager , Publicis Sapient

int[3][4] matrix = new int[3][4];

fillMatrix(matrix);

for(int i =0; i < matrix.length; ++i) {

    for(int j =0; j < matrix[i].length; ++j)  {

        // access matrix[i][j] and do something

    }

}

Your example is not clear. However, nested for-loops are what is used for multidimensional arrays, which are called matrices once they're above1 dimension.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?