ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل ramaswami s
تاريخ النشر: 2013/11/11
Daanish Rumani
من قبل 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.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟