1 / 32

Java Collections | Collections Framework in Java | Java Tutorial For Beginners | Edureka

**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training **** <br>This Edureka tutorial on u201cJava Collectionsu201d will talk about the complete hierarchy of Collections Frameworks in Java. It will walk you through the various fundamentals of collections like Lists, Queue, Sets, Interfaces etc. Through this tutorial you will learn the following topics: <br>Java Collection Framework <br>Collection Framework Hierarchy <br>Interfaces <br>List <br>Queue <br>Set <br><br>Check out our Java Tutorial blog series: https://goo.gl/osrGrS <br><br>Check out our complete Youtube playlist here: https://goo.gl/gMFLx3

EdurekaIN
Download Presentation

Java Collections | Collections Framework in Java | Java Tutorial For Beginners | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Topics for Today’s Session Java Collection Framework Queue Interfaces Collection Framework Hierarchy List Set JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  2. Java Collection Framework

  3. Java Collection Framework 01 Collections are the containers that groups multiple items in a single unit It provides an architecture to store and manipulate a group of objects 02 Using Java Collections various operations can be performed on the data like searching, sorting, insertion, manipulation, deletion, etc. 03 Java Collection framework provides many interfaces and classes 04 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  4. Java Collection Framework Heirarchy

  5. Collection Framework Hierarchy Iterable Interface Class Extends Collection Implements List Queue Set PriorityQueue HashSet ArrayList Deque LinkedHashSet LinkedList ArrayDeque SortedSet Vector TreeSet Stack JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  6. Collection Framework Hierarchy Interface Class Map Extends Implements HashMap HashTable Iterable Collection SortedMap List Queue Set PriorityQueue HashSet ArrayList Deque LinkedHashSet TreeMap LinkedList ArrayDeque SortedSet Vector TreeSet Stack JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  7. Java Interfaces

  8. Interface Interfaces are the reference types which are similar to classes but contains only abstract methods An interface can extend multiple interfaces Interface is implemented by a class Contains only abstract methods Interface do not contain constructors or instance fields Interface cannot be instantiated JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  9. Interface Iterator The Iterator interface provides the facility of iterating the elements only in a forward direction. Methods public boolean hasNext() public Object next() public void remove() The Iterable interface is the root interface for all the collection classes. The Collection interface along with all its subclasses also implement the Iterable interface. Iterable Methods Iterator<T> iterator() Collection interface is implemented by all the classes in the collection framework & declares the methods that every collection will contain Collection Methods Boolean add(Object obj) Boolean addAll(Object obj) void clear() ... JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  10. Java Lists

  11. Java List Java List is an interface that extents the Collection and contains ordered collection of elements including duplicate values LinkedList Vector ArrayList List Types JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  12. Java List ArrayList is the implementation of List Interface where the elements can be dynamically added or removed from the list The size of the list is increased dynamically if the elements are added more than the initial size ArrayList LinkedList 0 1 2 3 4 5 Vector ArrayList object = new ArrayList (); JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  13. Java List java.utils.ArrayList ArrayList void add(int index, Object element) boolean add(Collection c) void clear() LinkedList Vector int lastIndexOf(Object o) Object clone() Object[] toArray() void trimToSize() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  14. Java List Linked List is a sequence of links which contains items Each link contains a connection to another link ArrayList Linkedlist object = new Linkedlist(); LinkedList Vector Singly Linked List Doubly Linked List JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  15. Java List Singly Linked List Doubly Linked List ArrayList Each node in this list stores the data of the node and a pointer or reference to the next node in the list LinkedList HEAD Vector Prev Next Prev Next Prev Next NULL JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  16. Java List Singly Linked List Doubly Linked List Doubly Linked list has two references: one to the next node and another to previous node ArrayList HEAD LinkedList Prev Node Next Vector Prev Node Next Prev Node Next NULL JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  17. Java List Java.util.Linkedlist ArrayList void add (int index, Object element) boolean add(Object c) boolean contains(Object o) LinkedList void addFirst(Object o) void addLast(Object o) Vector int size() boolean remove(Object o) int indexOf(Object element) int lastIndexOf(Object element) JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  18. Java List Vectors are similar to arrays, where the elements of the vector object can be accessed via an index into the vector Vector implements a dynamic array and is not limited to a specific size and is synchronized ArrayList LinkedList Vector object = new Vector(size,increment); Vector 0 1 2 3 4 5 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  19. Java List Java.util.Vectors ArrayList void add (int index, Object element) boolean add(Object c) LinkedList boolean contains(Object element) void clear() Vector int size() boolean remove(Object o) int indexOf(Object element) int lastIndexOf(Object element) JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  20. Java Queue

  21. Java Queue Queue in Java follows a FIFO approach i.e. it orders the elements in First In First Out manner The first element is removed first and last element is removed in the end Queue<Integer> q = new LinkedList<>(); 0 1 2 3 n … … … Insert Remove Rear Front JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  22. Java Queue Java.util.Queue boolean add(object) boolean offer(object) Object remove() Object poll() Object element() Object peek() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  23. Java Set

  24. Java Sets A Set refers to a collection that cannot contain duplicate elements It is mainly used to model the mathematical set abstraction Set has its implementation in various classes HashSet LinkedHashSet TreeSet JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  25. Java Sets Java HashSet class creates a collection that use a hash table for storage HashSet Hashset only contain unique elements and it inherits the AbstractSet class and implements Set interface LinkedHashSet It uses a mechanism hashing to store the elements TreeSet HashSet<String> al= new HashSet(); JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  26. Java Sets Java.util.HashSet HashSet boolean add(Object c) boolean contains(Object o) LinkedHashSet void clear() boolean isEmpty() TreeSet int size() boolean remove(Object o) Object clone() Iterator iterator() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  27. Java Sets Java LinkedHashSet class is a Hash table and Linked list implementation of the set interface It contains only unique elements HashSet It provides all optional set operations and maintains insertion order LinkedHashSet LinkedHashSet<String> al=new LinkedHashSet(); This class inherits methods from other classes TreeSet HashSet AbstractSet AbstractCollection Object Set JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  28. Java Sets TreeSet class implements the Set interface that uses a tree for storage HashSet The objects of this class are unique and are stored in the ascending order LinkedHashSet It inherits AbstractSet class and implements NavigableSet interface TreeSet TreeSet<String> al=new TreeSet<String>(); JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  29. Java Sets Java.util.TreeSet HashSet boolean contains(Object o) boolean isEmpty() boolean addAll(Collection c) LinkedHashSet boolean remove(Object o) void add(Object o) void clear() TreeSet Object clone() Object first() Object last() int size() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

More Related