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 [ … ]
Category: Java
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 [ … ]
String Literals
Group of characters enclosed in double quotes is called as String literals.Example:String s=”Webnoid”; They may not contain new line or line feed.
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 [ … ]