Declaring and Initializing Arrays in Java || Lesson 52 || Java Programming || Learning Monkey ||

Опубликовано: 21 Июль 2023
на канале: Learning Monkey
128
4

Declaring and Initializing Arrays in Java
In this class, We discuss Declaring and Initializing Arrays in Java.
The reader should have prior knowledge of the class and object. Click Here.
Array:
An array is a sequence of homogeneous elements.
The below diagram shows the array of six elements.
The diagram shows how elements are stored in Random access memory.
The array index starts from zero.
a[2] is the way to access elements in position two.
The below example shows the declaration of the array.
class test
{
public static void main()
{
int[] a;
a= new int[10];
a[0]=10;
a[1]=20;
System.out.println(a[0]);
}
}
int[] a; is used to declare an array variable.
We create an array object using a new keyword.
The above two declaration and object creation lines can be done in the same line.
class test
{
public static void main()
{
int[] a= new int[10];
a[0]=10;
a[1]=20;
System.out.println(a[0]);
}
}
array initialization done using the syntax int[] a = {1,2,5,10};

Link for playlists:
   / @learningmonkey  


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


На этой странице сайта вы можете посмотреть видео онлайн Declaring and Initializing Arrays in Java || Lesson 52 || Java Programming || Learning Monkey || длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Learning Monkey 21 Июль 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 128 раз и оно понравилось 4 зрителям. Приятного просмотра!