Benefits of arrays

0 votes

The benefits of a list over an array, in my opinion, are rather clear:

  • List<Integer>, List<? extends Number>, and List<? super Integer> are examples of generics that offer more exact typing.
  • addAll, remove, and other helpful methods are available on a List interface. While for arrays all common operations—aside from get and set—must be carried out procedurally by sending the object to a static method.
  • Different implementations, such as ArrayList, LinkedList, unmodifiable, and synchronised lists, are available in collections and can be buried behind a single List interface.
  • OOB length control.
The disadvantages that I can think is the lack of syntactic helper and runtime check type. Still, the support for both structures needs use of asList and toArray methods, but this makes the code less readable.
So, what are the other points that I missed?
Aug 3, 2022 in Java by krishna
• 2,820 points
393 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Java

0 votes
1 answer

Cannot read property 'push' of undefined when combining arrays

The reason why you get this ERROR ...READ MORE

answered Feb 11, 2022 in Java by Rahul
• 9,670 points
1,811 views
0 votes
0 answers

What is the difference between List.of and Arrays.asList?

In java 9, new factory methods for ...READ MORE

Aug 2, 2022 in Java by krishna
• 2,820 points
510 views
0 votes
0 answers

Sort arrays of primitive types in descending order

I got a huge array of double ...READ MORE

Aug 3, 2022 in Java by krishna
• 2,820 points
686 views
0 votes
0 answers

Arrays of different types

Is it possible to have an array ...READ MORE

Aug 8, 2022 in Java by krishna
• 2,820 points
246 views
0 votes
2 answers

One line initialization of an ArrayList object in Java

In Java 8 or earlier: List<String> string = ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,220 points
4,153 views
0 votes
1 answer

How do I create a Java string from the contents of a file?

If you're looking for an alternative that ...READ MORE

answered Apr 19, 2018 in Java by Rishabh
• 3,620 points
939 views
0 votes
0 answers
0 votes
1 answer

what are the ways in which a list can be iterated

  There are 5 ways to iterate over ...READ MORE

answered Apr 23, 2018 in Java by sharth
• 3,370 points
925 views
0 votes
2 answers

What is the difference between Set and List in java?

List is an ordered sequence of elements. ...READ MORE

answered Apr 26, 2018 in Java by Akrati
• 3,190 points
62,725 views
+1 vote
3 answers

How to convert a List to an Array in Java?

Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE

answered Aug 7, 2018 in Java by Akrati
• 3,190 points
881 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP