Course Content

Course Content


The array's size must be provided at declaration. The array's size during declaration instructs the compiler to allocate and reserve the memory regions provided. Data items of type int, char, and so on can be used to initialise array elements.

Initializing Elements and Declaring an Array At the moment of declaration, an array can be initialised. The compiler will allocate an array of size equal to the number of array elements in this method of array declaration. To declare and initialise an array at the same time, use the following syntax.

An array index is the name given to the number. In Java, we can also use the index number to initialise arrays. / declare an array int[] age = new int[5]; / initialise array age[0] = 12; age[1] = 4; age[2] = 5; and so on.

Initialization of a single-dimensional array. Array initialization is the process of assigning values to array elements. Before an array can be utilised in a programme, its elements must be initialised once it has been specified. The programme provides unexpected results if they are not correctly initialised.

There are two ways to provide array initializers:

  • Array elements must be initialised in subscript order when using C89-style initializers.
    Array elements can be initialised in any order using defined initializers, which allow you to specify the values of the subscript components to be initialised.

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere