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,140 points
2,567 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
63,360 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
22,551 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,909 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,485 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
28,245 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
625 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
804 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
2,324 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