Can we use array elements before initialization?
class Array7
{
public static void main(String[] args)
{
int[] x=new int[3];
System.out.println(x[0]);
}
}
/*
Output:- 0(Zero)
Explanation:- Once we created an array, its elements are by default initialized with
default values. int data type default value is 0(zero).
*/
{
public static void main(String[] args)
{
int[] x=new int[3];
System.out.println(x[0]);
}
}
/*
Output:- 0(Zero)
Explanation:- Once we created an array, its elements are by default initialized with
default values. int data type default value is 0(zero).
*/
0 comments: