Loading...

Category: Java

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 [ … ]

Char Literals

A char literal can be represented as single character with single quotes.Example:1. char c=’a’; //(valid)2. char c=”a”; //(invalid)3. char c=a; //(invalid)4. char c=’abc’; //(invalid) Char literal can also be specified [ … ]