What is Array?

• An array is a container object that holds a fixed number 
of values of a single type. The length of an array is established 
when the array is created. After creation, its length is fixed. 
You have seen an example of arrays already, in the main 
method of the "Hello World!" application.
This section discusses arrays in greater detail. 
• Each item in an array is called an element, 
and each element is accessed by its numerical index.

• Advantage of Java Array 
o Code Optimization: It makes the code optimized, 
we can retrieve or sort the data easily. 
o Random access: We can get any data located at any index position. 
• Disadvantage of Java Array 
o Size Limit: We can store only fixed size of elements in the array. 
It doesn't grow its size at runtime. To solve this 
problem, collection framework is used in java.

4.13
8
Awgiedawgie 440215 points

                                     // *** An array is a collection of data items, all of the same type,
 //     accessed using a common name

int main()
{
 
    // Creating an integer array named arr of size 10.
    int arr[10];
    // accessing element at 0 index and setting its value
    // to 5.
    arr[0] = 5;
    // access and print value at 0 index we get the output
    // as 5.
    printf("%d", arr[0]);
 
    return 0;
}

4.13 (8 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source