Can we declare,create,initialize array in multiple line?
class Array13
{
public static void main(String[] args)
{
int[] x;
x={10,20,30};
System.out.println(x);
}
}
/*
Output:- CE[illegal start of expression]
Explanation:- If we use shortcut to create and initilize the array then it is compulsary
to write in a single line only. If we are trying to divide into multiple lines
then we will get compilation error.
*/
{
public static void main(String[] args)
{
int[] x;
x={10,20,30};
System.out.println(x);
}
}
/*
Output:- CE[illegal start of expression]
Explanation:- If we use shortcut to create and initilize the array then it is compulsary
to write in a single line only. If we are trying to divide into multiple lines
then we will get compilation error.
*/
0 comments: