Computer Science, asked by kbhatia2637, 5 months ago

what is right way to initialize arrey

Answers

Answered by BrainlyProgrammer
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