Variables are divided into three types based on behavior and position of declaration. They are:1. Instance Variables2. Static Variables3. Local Variables Instance Variables: –> Instance variables are the variables which [ … ]
Array Variable Assignments
Element level promotions are not applicable at array object level.Example: A char value can be promoted to int type but char array cannot be promoted to int array.Example:int[] x={5, 10, [ … ]
Array Element Assignments
In primitive arrays as array elements is allowed which can be promoted to declare type.Example:For int arrays allowed array elements types are byte, short, char, int. int[] a=new int[10];a[0]=86;a[1]=’x’;byte b=10;a[2]=b;short [ … ]
Anonymous Arrays
Array created with no name are called anonymous array. The main objective of this array is for instant use (i.e., just for one instant use). Example:1. new int[] {5,10,15,20};2. new [ … ]
length Vs length() Method
length:It is the applicable only for array. It represents the size of the arrayExample:int[] array=new int[5];System.out.println(array.length);Output:5 In multidimensional array length represents only base size not a total sizeExample:int[][] arr=new int[5][3];System.out.println(arr.length); [ … ]
Array
Array is collection of fixed number of homogeneous data elements.We can represent multiple values with the same variable name so that readability of the code will be improved. The size [ … ]