Arrays: ======= variable ==> named container store the value Syntax: datatype variable-name = value; int x = 10; x = 20; Is it possible to store multiple values in one variable? ======================================================== ex: int a = 1,2,3,4; ==> Incorrect representation Arrays: ======= ==> Array is an object ==> can be represented with an identifier/name to represent the memory storage ==> is the collection of similar data items. ex: [1,2,3,4,5] [1.2f,2.3f,3.4f] ==> array elements/items can store in heap memory. ==> array can reserve with contiguous memory. ==> Array elements/items can access with a positive index values. 0 to n-1 Syntax: array-name[index-value] ==> can helps to access the individual elements class A{ int a = 100; } obj = A() obj.a Scanner nextInt() nextFloat() Where arrays can use? ===================== ICICI Bank{ lacks of people ==> Subscribers of ICICI } Advantages: =========== 1) Optimize the code 5-students 5-marks stu1 = {s1,s2,s3,s4,s5} Disadvantage: ============= Array size cannot be dynamically change. ==> Arrays can be classified into three types: ================================================ 1) Single Dimensional Array 2) Two Dimensional Array 3) Multi-Dimensional Array Single Dimensional Array ========================= ==> also called as "one dimensional arrays". Syntax: (for declaration) 1) datatype[] identifier; 2) datatype []identifier; 3) datatype identifier[]; JRE System Library SRC package Java_Arrays; public class OneDimensionalArray { public static void main(String[] args) { // Declaring of character array char[] a1 = {'a','e','i','o','u'}; // integer array declaration int []a2 = {1,3,5,7,9,9,7}; // float array declaration float a3[] = {0.1f,0.2f,0.3f}; // when the array is declared but not initialized: // by default the array elements can be fill with 0 System.out.println(a1[1]); System.out.println(a2[3]); System.out.println(a3[0]); } } ==================================== Instantiation of array definition: ================================== Syntax: datatype[] array-name = new datatype[size]; ==> default value for array element ==> 0 (integer array)