Various Types of Interface in Java explained

a. Set Interface in Java

Set accumulation that doesn’t permit copies and furthermore doesn’t permit getting to components by index. Rather, it gives techniques that check if component or components exist.

  • EnumSet — Enumset particular class to work with enum types.
  • HashSet — HashSet keeps an unordered list of components (arrange is eccentric).
  • LinkedHashSet — LinkedHashSet keeps requested rundown of components.
  • TreeSet — Treeset makes sure that there are no duplicates.
  • SortedSet — Sortedset provides ordering on its elements.

b. Java List Interface

Java list is accumulation that permits copies and carries on, like arrays (file components by the whole number) yet is more adaptable. To start with component has list = 0, last one has record = length-1.

  • ArrayList — Keeps an unordered list of components utilizing exhibit.
  • LinkedList — Keeps requested list of components utilizing doubly-connected rundown.
  • Vector — For the most part, the same as ArrayList, however, it is string safe.

c. Map Interface in Java

Java Map Interface is accumulation that permits copies and is like rundown with the exception of that record components by (key can be any protest) Map can be expected as an affiliated exhibit.

  • HashMap — Keeps unordered rundown of list utilizing exhibit
  • LinkedHashMap — Keeps requested list of components utilizing doubly-connected rundown.
  • TreeMap — Keeps requested list of components utilizing RBT. Components are requested by regular request or by a custom comparator.
  • Hashtable — Keeps an unordered list of components as HashMap, however, it is synchronized. This class is outdated.
  • EnumMap — Keeps ordered collection and are maintained in natural order.
  • Properties — It is subclass of HashTable. Provides methods to read and store data in properties file.

Related blog:

Spring boot interiview questions