List :
It is an interface inheritd from Collections for ordered collection of objects.
It can contain duplicate elements.
How is ArrayList different from Array?
See :How to sort an Array List without using Comparator or sort method
For internal working of Array List Read: Internal worling of ArrayList
How to convert an array to a list?
using Arrays.asList() method.
ArrayList and LinkedList
Implements Iterator interface.
List Iterator methods ->
1.hasnext()
2. next()
3. hasprevious()
4. previous
5. nextindex();
6. previousindex();
7. remove()
8. add();
9. set()
See :Java Collection-Set
Static varibale,static class,Static method
It is an interface inheritd from Collections for ordered collection of objects.
It can contain duplicate elements.
How is ArrayList different from Array?
Array
| |
Is not definite in size. Can expand according to requirement.
|
Is definite in size.
|
Stores objects
|
Store primitive data.
|
Is present in collections
|
framework Present in lang package
|
See :How to sort an Array List without using Comparator or sort method
For internal working of Array List Read: Internal worling of ArrayList
How to convert an array to a list?
using Arrays.asList() method.
ArrayList and LinkedList
Array List and Link List are two classes that implements List Interface .
ArrayList -> is an array based representation of list.
Can be accessed using get and set methods.
Used for simple sequence.
Linked List->
Based on Link List representation.
Give good performance with add() and remove()n methods.
Gives poor performance with get() set() methods.
List Iterator
Implements Iterator interface.
List Iterator methods ->
1.hasnext()
2. next()
3. hasprevious()
4. previous
5. nextindex();
6. previousindex();
7. remove()
8. add();
9. set()
See :Java Collection-Set
No comments:
Post a Comment