what is right way to initialize arrey
Answers
Answered by
3
Following statement is to initialise an array in Java,
int a[]={1,2,3,4,5,6}; //to store numbers
Same way you can initialize in double,float,char and String.
Note:-
- To initialize char data type array you must enclose each elements with single quotes. Example: char c[]={'a','b','c'};
- To initialize String data type array you must enclose each elements with double quotes. Example: String s[]={"Abcd","Hello","Brainly"};
Similar questions
Social Sciences,
2 months ago
English,
2 months ago
Social Sciences,
5 months ago
English,
5 months ago
Biology,
10 months ago
Science,
10 months ago