You are on page 1of 2

arrays:

In programming, the use of variables is quite necessary, but it is not always possible to work with
the same variable since sometimes the use of these variables is not limited to a single data at a
time, to solve this problem, the arrays that are memory spaces capable of storing more than one
data at a time to be used at any time.

As can be seen in the image, while the variable "X" stores only one value at a time, the array "Z"
can store 4 at the same time, without the need to name more variables within the program.

There are different types of arrays, these are divided into alphanumeric arrays, types of arrays
where numbers and letters enter equally, although if it is configured in this way it will not be
possible to do operations with these numbers and there are also numeric arrays, in these arrays if
It is possible to do operations, but as its type says it will only admit numbers.

To start filling an array in JAVA, it is necessary first of all to initialize it, this means that, before
entering the data to the array, it is required to say exactly what the array will be called, what type
of data it will receive and how much data will this be as follows way.

(Data type) [] (Array name) = new (Data type) [(Amount of data)];

example:

Int [] array = new int [5];

After this we continue with the process of filling the array, to fill an array in any programming
language it is necessary to start from 0, every array must start filling from 0 to the number less
than its limit, in this way:

array [0] = 1;

array [1] = 5;

array [2] = 2;

array [3] = 6;

array [4] = 7;
Matrix:

In the case of matrices, it can be said that a matrix is an information base, a set of data ordered by
rows and columns, in the previous description it was said that an array is a variable but with more
memory spaces, the difference is more The important thing between a matrix and an array is that
the matrix is two-dimensional, while an array can only have more than one row or one column at a
time, a matrix is capable of having any number of rows or any number of columns, Thanks to the
order of the matrices, a search can be carried out within this same matrix faster than within an
array.

The way an array works is exactly the same as the way an array works, the data must be entered
one by one until all of it is filled and matrices of different types can exist as in the case of arrays.

In JAVA an array is initialized as follows:

(Data type) [][] (Matrix name) = new (Data type) [rows][columns];

So that in the end I was as follows:

Int [][] matrix = new int [2][2];

Matrix [0][0] = 4;

Matrix [0][1] = 3;

Matrix [1][0] = 7;

Matrix [1][1] = 9;

You might also like