Академический Документы
Профессиональный Документы
Культура Документы
Week 2: Arrays
An array is a collection of variables of the same type. It stores a fixed size sequential collection of
elements of the same type. An array is used to store a collection of data.
Arrays are declared with [] (square brackets). If you put [] (square brackets) after any variable of any
type only that variable is of type array remaining variables in that declaration are not array variables
those are normal variables of that type. If you put [] (square brackets) after any data type all the
variables in that declaration are array variables. All the elements in the array are accessed with index.
The array element index is starting from 0 to n-1 number i.e. if the array has 5 elements then starting
index is 0 and ending index is 4. In this tutorial you can learn how to declare arrays, how to assign
values to arrays and how get values from arrays.
Syntax:
<data type> <variable>[];
<data type>[] <variable>;
boolean Array
It is used to store boolean data type values only. With the following examples you can learn how to
declare boolean array, how to assign values to boolean array and how to get values from boolean array.
In this example you can learn how to assign values to boolean array at the time of declaration.
In this example you can learn how to declare boolean array with other boolean variables.
In this example you can learn how to assign boolean array to other boolean array.
byte Array
It is used to store byte data type values only. With the following examples you can learn how to declare
byte array, how to assign values to byte array and how to get values from byte array.
In this example you can learn how to assign values to byte array at the time of declaration.
In this example you can learn how to declare byte array with other byte variables.
In this example you can learn how to assign byte array to other byte array.
char Array
It is used to store char data type values only. With the following examples you can learn how to declare
char array, how to assign values to char array and how to get values from char array.
In this example you can learn how to assign values to char array at the time of declaration.
In this example you can learn how to declare char array with other char variables.
In this example you can learn how to assign char array to other char array.
short Array
It is used to store short data type values only. With the following examples you can learn how to declare
short array, how to assign values to short array and how to get values from short array.
In this example you can learn how to assign values to short array at the time of declaration.
In this example you can learn how to declare short array with other short variables.
In this example you can learn how to assign short array to other short array.
int Array
It is used to store int data type values only. With the following examples you can learn how to declare
int array, how to assign values to int array and how to get values from int array.
In this example you can learn how to assign values to int array at the time of declaration.
In this example you can learn how to declare int array with other int variables.
In this example you can learn how to assign int array to other int array.
float Array
It is used to store float data type values only. With the following examples you can learn how to declare
float array, how to assign values to float array and how to get values from float array.
In this example you can learn how to assign values to float array at the time of declaration.
In this example you can learn how to declare float array with other float variables.
In this example you can learn how to assign float array to other float array.
long Array
It is used to store long data type values only. With the following examples you can learn how to declare
long array, how to assign values to long array and how to get values from long array.
In this example you can learn how to assign values to long array at the time of declaration.
In this example you can learn how to declare long array with other long variables.
In this example you can learn how to assign long array to other long array.
double Array
It is used to store double data type values only. With the following examples you can learn how to
declare double array, how to assign values to double array and how to get values from double array.
In this example you can learn how to assign values to double array at the time of declaration.
In this example you can learn how to declare double array with other double variables.
In this example you can learn how to assign double array to other double array.