Java Arrays
Java Arrays
Array in Java:
An array is a container object that holds a fixed number of values of a single type
=========================================
3 basic information is needed to start with array
Datatype
Size of array
Data in array
=========================================
Things to do with array:
creation (datatype and size is required)
initialization (datatype, size and values is required)
manipulations
3.initialization of array(object initialization using constructor calling i.e putting values inside an array)
using new keyword
nameOfArray[index]=val1, nameOfArray[index]=val2,
Note :
Array are created using two ways new keyword and using literal
if we have size and elements are defined then literal is used
when only datatype and size is known then new keyword is used
--------------------------------------------------------------------------
Manipulation of array :
Arrays are manipulated using their index values
Array index value start from the 0
study yourself the multiplication, addition of elements in array and between to array
=========================================
Array can be classified using Dimension
--------single dimension --------------
1Dimension: dataType nameOfArray[ ];
--------multidimensional Array---------
2Dimension: dataType nameOfArray[ ][ ];
Note: all these arrays are created using same process as mentioned above
jaggerd array:
Final array:
=======================================
Final Note : arrays created using this method are static in nature as size of an array is immutable can’t be changed
dynamic arrays are created using Arraylist class
---------------------------------------------------------------------------the End---------------------------------------------------------------