Can we create an array of zero size?

class Array3
{
public static void main(String[] args)
{
int[] x=new int[0];
System.out.println(x);
}
}
/*
Output:- Reference value of the array
Explanation:- It is legal to have an array of zero size. Whenever we are trying to print
any object reference, internally toString() method is called. And toString() method
of Object class prints any object reference in this format.
ClassName@hexadecimal_hashcode
Ex:- [I@12b6651
For every Array type corresponding classes are available and these classes are the
part of Java language and not applicable to the programmer.
------------------------------------------------
ARRAY TYPE | CORRESPONDING CLASS NAME
------------------------------------------------
int[] | [I
int[][] | [[I
int[][][] | [[[I
byte[] | [B
short[] | [S
long[] | [J
float[] | [F
double[] | [D
boolean[] | [Z
char[] | [C
char[][] | [[C
*/

0 comments: