Java Array:

  • The array is a collection of elements of the same type that are nearby memory spaces.
  • We can store only a certain set of elements in a java array.
  • The array index is based, the first element of the array is stored in the 0 index.


Types of Array:

  1. One Dimensional Array
  2. Two Dimensional Array


Java program contains steps in array:

  1. Announce the name of the array.
  2. Create an array.
  3. Start array values.


Array Features:

  • It is always indexed. Index starts with 0.
  • This is a collection of similar data types.
  • It is in a closest memory place.


Array Pass with reference:

  • Arrays are passed in terms of reference, or as an indicator of origin.
  • This means that whatever array you make inside the function affects the root.


One dimensional array:

  • A one-dimensional array is like a spreadsheet with data in only one line.





  • An array declaration has two components: array type and array name.
  • The type of an array is written as type [], where type elements are the type of data; Brackets are special symbols which indicate that this variable holds an array.
  • The size of the array is not part of its type.
  • With other types of variables, the announcement does not actually make a Java array; It only tells the compiler that in this variable there will be an array of the specified type.




Another way of creating and initializing same one dimensional array is as shown below.


Two Dimensional Array:

  • In the Java software development language, two-dimensional array is like a spreadsheet with multiple rows and columns, each with different data in each slot.
  • Each cell will be identified by its unique line and column index combination (e.g. SR 1 [3] [2]).
  • We can use a two-dimensional array to store user IDs and passwords of different users.