1
visibility
Which one of the following is a valid statement?
- A
char[] c = new char();
- B
char[] c = new char[5];
- C
char[] c = new char(4);
- D
char[] c = new char[];
The syntax for declaring and creating an array in java is:
dataType[] arrayName = new dataType[arraySize];
Thus, option (A) and option (C) is syntactically wrong as parentheses( ( ) ) is used instead of square brackets( [ ] ).
Option (D) is incorrect as the size of the array is missing