Answer to Question #213011 in Java | JSP | JSF for lakli

Question #213011

Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components of an array Note: You will receive 4 marks for your explanation and 6 marks for your labelled example.


1
Expert's answer
2021-07-03T04:48:56-0400
An array is a collection that stores a fixed number of values of a same type. 


Examples:
Declaring an array:
// declares an array of integers
int[] ages;
// allocates memory for 10 integers
ages = new int[10];
// declares an array of strings
String[] names;
// allocates memory for 10 strings
names = new String[10];


Initializing array element:
String[] names= { "Peter", "Mary", "Mike",
                  "Denis", "Julia",
                  "Mark", "Olivia" };


String[] names= new Array[7];
names=[0] = "Peter"; 
names=[1] = "Mary"; 
names=[2] = "Mike";
names=[3] = "Denis"; 
names=[4] = "Julia";
names=[5] = "Mark";
names=[6] = "Olivia";




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS