One dimensional array in java

One dimensional array in java



Arrays are the collection of homogenous elements. In the sense they have same data type. Arrays can be declared as any dimensions.Each element of an array
is accessed by it’s index.

One dimensional array

It is a single list of same data type.The general form of an array is:
eg: type name[]
Here type indicate the data type of an array. Name indicates the name you wanna give to an array.Although you declared the array like this practically no array
exists, which represents the array with null value. In order to allocate the memory for this array one should declare it with new keyword.The syntax to allocate
memory for array is:
eg:name = new type [size];
Here type indicate the data type of array, size indicates number of elements in an array and name indicates the name of an array.
Let’s write a program for array demonstration:

Code goes here:

Link for online compiler(You can check the working of the program in this): click here.


Java The Complete Reference Eighth Edition

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger