What is the difference between Type List and type ArrayList in Java

0 votes
Typelist v/s ArrayList. If anybody can help?
Jul 9, 2018 in Java by Daisy
• 8,120 points
2,266 views

2 answers to this question.

0 votes

Always TypeList is preferred over ArrayList. The first has the advantage that the implementation of the List can change without affecting the rest of the code. This will be a difficult task to do with an ArrayList, not only because you will need to change ArrayList to LinkedList everywhere, but also because you may have used ArrayList specific methods.

Hope this helps!

Check out Java online course to learn more about it.

Thanks!

answered Jul 9, 2018 by Akrati
• 960 points
0 votes

By List, you actually tell, that your object implements List interface only, but you don't specify what class your object belongs to.

By  ArrayList, you specify that your object class is a resizable-array.

So, the first version makes your code more flexible in future.

Class ArrayList - Resizable-array implementation of the List interface.

Interface List - An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted.

Array - container object that holds a fixed number of values of a single type.

answered Aug 28, 2019 by Sirajul
• 59,230 points

Related Questions In Java

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,763 views
0 votes
2 answers

What is the difference between getAttribute() and getParameter() in java?

getParameter() returns http request parameters. Those passed from ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
21,506 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

answered Jul 26, 2018 in Java by Mrunal
• 680 points
1,675 views
0 votes
2 answers

What is the difference between Map and HashMap in java?

The basic difference is : Map is ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
29,047 views
0 votes
1 answer

Which is faster amongst an Array and an ArrayList?

Array Over List: The capacity of an Array is fixed.  Whereas ArrayList can ...READ MORE

answered Jul 20, 2018 in Java by sophia
• 1,400 points
27,594 views
0 votes
0 answers
0 votes
0 answers
0 votes
0 answers

Benefits of arrays

The benefits of a list over an ...READ MORE

Aug 3, 2022 in Java by krishna
• 2,820 points
405 views
0 votes
1 answer

What is the use of StringBuilder in java?

If you use String concatenation in a ...READ MORE

answered Jun 19, 2018 in Java by Akrati
• 960 points
650 views
0 votes
1 answer

What does NaN mean in Java?

"NaN" stands for "not a number". "Nan" ...READ MORE

answered Jul 12, 2018 in Java by Akrati
• 960 points
1,705 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