answersLogoWhite

0


Best Answer

Arrays permit efficient (constant time) random access but not efficient insertion and deletion of elements. Consequently, arrays are most appropriate for storing a fixed amount of data which will be accessed in an unpredictable fashion.

Another advantage of arrays that has become very important on modern architectures is that iterating through an array has good locality of reference, and so is much faster than iterating through (say) a linked list of the same size, which tends to jump around in memory. However, an array can also be accessed in a random way, as is done with large hash tables, and in this case this is not a benefit.

Arrays also are among the most compact data structures; storing 100 integers in an array takes only 100 times the space required to store an integer, plus perhaps a few bytes of overhead for the whole array. Any pointer-based data structure, on the other hand, must keep its pointers somewhere, and these occupy additional space. This extra space becomes more significant as the data elements become smaller. For example, an array of ASCII characters takes up one byte per character, while on a 32-bit platform, which has 4-byte pointers, a linked list requires at least five bytes per character. Conversely, for very large elements, the space difference becomes a negligible fraction of the total space.

Because arrays have a fixed size, there are some indexes which refer to invalid elements - for example, the index 17 in an array of size 5. What happens when a program attempts to refer to these varies from language to language and platform to platform.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Advantages and disadvantages of arrays in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the advantages and disadvantages event handler to event properties?

what are the advantages and dis advantages of event handling in java


How do you find the difference between two arrays in Java?

for arrays you can list the different arrays and what attributes that you give to them.


Is Java better than Adobe Flash player?

Java and Flash Player are used for different purposes. They both have their advantages and disadvantages.


Where can one find advice about working with Java sorting arrays?

There are many places where one could find advice about working with Java sorting arrays. The best place to learn more about working with Java would be to contact Oracle.


Why net is better than java?

I suppose both have their advantages, and their disadvantages. Java is designed for multiple platforms; .NET is more focussed on Windows. There is, however, a "Mono" project that gives .NET certain compatibility with Linux.


What are the advantages and disadvantages of Enterprise Java Beans?

The advantage of Enterprise Java Beans is that they standardize coding thus expediting the fulfillment of application requirements. The disadvantage of Enterprise Java Beans is that their integration into an application is often complex and challenging.


Is it possible to use arrays when using the java programming language?

It is possible to use arrays when employing java programming language. There are many different series of programming choice that can be employed with various end results.


Can ragged arrays created by using java?

I assume you mean that you have a number of rows, and that not all rows have the same number of "cells". Yes, in Java a two-dimensional array is implemented as an array of arrays (each item in the top-level array is, in itself, an array); a 3-dimensional array is an array of arrays of arrays, etc.; and there is no rule stating that all secondary (etc.) arrays must have the same number of elements.


advantages and disadvantages of equity?

Advantages and Disadvantages of equity


What are advantages and disadvantages of artificial seasoning of timber?

advantages and disadvantages


Which one is better than arrays in java?

Better for what? Arrays have their purposes, other constructs have other purposes. Depending on what you need, an array may be just what you need.


What are Advantages and disadvantages of recession?

advantages and disadvantages of recession