Variable Length Two Dimensional Array || Lesson 55 || Java Programming || Learning Monkey ||

Опубликовано: 25 Июль 2023
на канале: Wisdomers - Computer Science and Engineering
733
17

Variable Length Two Dimensional Array
In this class, We discuss Variable Length Two Dimensional Array.
The reader should have prior knowledge of single-dimensional array declaration. Click Here.
Example 1:
We take an example and understand variable length arrays.
class test
{
public static void main(String args[])
{
int a[][] = {{1,2,5,10},{5,3,4,9,10},{6,2,5}};
int i,j;
for(i=0;ilt3;i++)
{
for(j=0;jlta[i].length;j++)
{
System.out.println(a[i][j]);
}
}
}
}
We initialized the array "a";
Each line has a different number of elements.
This variable length array allocation is allowed in Java.
The below diagram shows the memory allocation to variable-length two-dimensional arrays.
We use length attributes on arrays to access the elements in a variable length array.
The inner loop uses the "a[i].length" to find the array's length.
The below diagram shows the dynamic way to define a variable length array.
class test
{
int[][] a = new int[3][];
a[0]= new int[5];
a[1]= new int[2];
a[2]= new int[4];
a[2][3]=10;
System.out.println(a[2][3]);
}
}
Link for playlists:
   / @wisdomerscse  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ learningmonkey01@gmail.com


На этой странице сайта вы можете посмотреть видео онлайн Variable Length Two Dimensional Array || Lesson 55 || Java Programming || Learning Monkey || длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Wisdomers - Computer Science and Engineering 25 Июль 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 733 раз и оно понравилось 17 зрителям. Приятного просмотра!