The document discusses Java collections framework. It describes that the framework includes interfaces like List, Set, and Map that define different types of collections. It also discusses some implementations of these interfaces like ArrayList, LinkedList, Vector. ArrayList is like an array but resizable, while LinkedList stores elements in memory locations linked by addresses, making insertion/deletion faster than ArrayList. The document also covers methods of collections like add, remove, contains.
To learn important concept of Collection and its handling plus its advantages and different class & child class of Collection and their implementations. Important interview questions of the collection.
This presentation introduces some concepts about the Java Collection framework. These slides introduce the following concepts:
- Collections and iterators
- Linked list and array list
- Hash set and tree set
- Maps
- The collection framework
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
To learn important concept of Collection and its handling plus its advantages and different class & child class of Collection and their implementations. Important interview questions of the collection.
This presentation introduces some concepts about the Java Collection framework. These slides introduce the following concepts:
- Collections and iterators
- Linked list and array list
- Hash set and tree set
- Maps
- The collection framework
The presentation is took from the Java course I run in the bachelor-level informatics curriculum at the University of Padova.
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” 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:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Java Collections Framework Inroduction with Video TutorialMarcus Biel
This presentation is part of my free Java 8 course focusing on clean code principles. In this piece, you will be given a high-level introduction of the Java Collections Framework (JCF).
You can find the full article with lots of other additional materials here -
http://www.marcus-biel.com/java-collections-framework/
Collections Framework is a unified architecture for managing collections, Main Parts of Collections Framework
1. Interfaces :- Core interfaces defining common functionality exhibited by collections
2. Implementations :- Concrete classes of the core interfaces providing data structures
3. Operations :- Methods that perform various operations on collections
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Edureka!
**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****
This Edureka tutorial on “Java Collections” 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:
Java Collection Framework
Collection Framework Hierarchy
Interfaces
List
Queue
Set
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Java Collections Framework Inroduction with Video TutorialMarcus Biel
This presentation is part of my free Java 8 course focusing on clean code principles. In this piece, you will be given a high-level introduction of the Java Collections Framework (JCF).
You can find the full article with lots of other additional materials here -
http://www.marcus-biel.com/java-collections-framework/
Goal of the session is to show ways of identifying badly written code in long term perspective. As an example a OSS e-commerce platform was examined and the results will be discussed during session. I will also show waht we, as developers, should pay attention while doing out daily programming routines. Both programmers and other team members will be able to identify committed code crimes :)
VIEW26 - for software quality professionalsAjay Emmanuel
View26™ is a powerful analytics solution designed for the software quality assurance professionals. View26™ brings to you features like instant dashboards, end-to-end integration to popular testing tools, built-in capability to merge and correlate multiple testing tools or data sources, complete mobility and many more. Eliminate non-value adding tasks, gain more testing time and implement data driven risk based testing strategy.
Blue-Green Deployment é uma técnica robusta e segura, que consiste em manter dois ambientes de produção identicos rodando em paralelo (blue e green), alternando o tráfego entre eles, conforme a necessidade. Esta abordagem permite uma redução no downtime durante o deploy, com a segurança de rollback no caso de falhas, mas exige mais máquinas e um complexo sistema de orquestração. Nesta palestra, é demonstrado como realizar deploys sem downtime através do Docker, que torna o processo incrivelmente fácil e simplificado.
Main goal of this session is to explain in details core aspects of SOLID principles. Code samples are in C# , but SOLID principles are language agnostic and should be applied by any software engineer regardless used programming language.
The goal of the session is to show the history, theory and practice of the SOLID principles in business and technical context of created software system.
Examples will be presented in C# language, but SOLID principles can and should be applied by every software engineer regardless of the used programming language
Apresentação sobre qualidade de software, mostrando alguns dos fatores que a influenciam, tipos de testes, além de abordagens para torná-la uma das prioridades da equipe.
Existem diversos aspectos que devem ser priorizados ao se escrever uma API. Bom entendimento do domínio, arquitetura ideal, boa estratégia de testes, etc. Esses são alguns dos problemas reais e prioritários existentes. JSON API é uma ótima solução para evitar a perda de tempo tentando reinventar a roda durante a definição do design das respostas de sua aplicação. Nesta apresentação, alguns exemplos de uso, considerações/vantagens e dicas de como tornar a sua aplicação compatível sem (muita) dor.
As predicted by Gartner, the demands for API testing and virtualization services are expected to rise exponentially because of the increasing intricacies in business logics and quickly changing IT environments. Independent software testing companies take a clue and explore this avenue.
Read More at: http://softwaretestingsolution.com/blog/api-testing-keeping-check-agile-software-development/
This lecture is about the detail definition of software quality and quality assurance. Provide details about software tesing and its types. Clear the basic concepts of software quality and software testing.
In this session you will learn:
List – ArrayList, LinkedList
Set – HashSet, LinkedHashSet, TreeSet
For more information: https://www.mindsmapped.com/courses/software-development/become-a-java-developer-hands-on-training/
Collections in .net technology (2160711)Janki Shah
Collections in .NET Framework.
- What is collections?
- Needs of Collections/ importance of collection
- various most useful classes of collection such as
ArrayList, Hashtable, Stack, Queue, BitArray, SortedList
WHAT ARE COLLECTIONS?
Collections store arbitrary objects in a structured manner. Types of collections available within the .NET Framework are:
ARRAYS
ADVANCED COLLECTIONS -
i) Non - Generics
ii) Generics
In this core java training session, you will learn Collections. Topics covered in this session are:
• Recap of Arrays
• Introduction to Collections API
• Lists – ArrayList, Vector, LinkedList
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
The Collection in Java is a framework that provides an architecture to store and manipulate the group of objects.
All the operations that you perform on a data such as searching, sorting, insertion, manipulation, deletion, etc. can be achieved by Java Collections.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque, etc.) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet, etc.).
Collections and its types in C# (with examples)Aijaz Ali Abro
Learn step by step c# collections with easy examples. Learn generic, non-generic and specialized collections along with easy and great examples. Learn about arraylist, queue class,stack class and more. Difference between generic and non-generic collections. Difference between arraylist and simple array.
1. Collections Framework
• Collection represents a group of objects, known as its elements
• Group of classes and interface.
• Can store objects in collection classes.
2. • (lowercase c) collection framework represents any of the data structures in
which objects are stored & retrieved.
• (Uppercase C ends with s) Collections – java.util.Collections class – holds
static utility methods.
• (Uppercase C) Collection is an Interface set the standard for Collection
classes so that they will have uniform method names.
• The five legacy classes: Vector, HashTable, Properties, Directory, Stack
and one legacy interface: Enumeration
• There are some problems with the above legacy classes. In order to avoid
those problems, SUN has introduced Collection framework in Java 2.
• Three categories:
• List - Collection of object with duplicate
• Set - Collection of object without duplicate
• Map - Collection of key / value pairs
3.
4. Collections
- The java.util package contains one of Java’s most powerful subsystems: collections.
Collections were added by the initial release of Java 2, and enhanced by Java
2,version 1.4. A collection is a group of objects
- In addition to collections, java.util contains a wide assortment of classes and
interfaces that support a broad range of functionality.
- The Java collections framework standardizes the way in which groups of objects are
handled by your programs.
- The collections framework was designed to meet several goals.
i. The framework had to be high-performance. The implementations for the
fundamental collections (dynamic arrays, linked lists, trees, and hash tables) are
highly efficient.
ii. The framework had to allow different types of collections to work in a similar
manner and with a high degree of interoperability.
iii. Extending and/or adapting a collection had to be easy.
5.
6. Collection Interfaces
The collections framework defines several interfaces. Beginning with the collection
interfaces is necessary because they determine the fundamental nature of the
collection classes
But there are sub flavors within those three types:
7. Ordered
- When a collection is ordered, it means you can iterate through the collection in a
specific (not-random) order.
- A Hashtable collection is not ordered. Although the Hashtable itself has internal logic
to determine the order (based on hashcodes and the implementation of the collection
itself), you won’t find any order when you iterate through the Hashtable.
- An ArrayList, however, keeps the order established by the elements’ index position
(just like an array).
- LinkedHashSet keeps the order established by insertion, so the last element inserted
is the last element in the LinkedHashSet (as opposed to an ArrayList where you can
insert an element at a specific index position).
Sorted
- For a collection of String objects, then, the natural order is alphabetical.
- For Integer objects, the natural order is by numeric value.
- A sorted collection means a collection sorted by natural order.
- And natural order is defined by the class of the objects being sorted
10. List Interface
The List interface extends Collection and declares the behavior of a collection that
stores a sequence of elements. Elements can be inserted or accessed by their position
in the list, using a zero-based index. A list may contain duplicate elements.
The three List implementations are described in the following section.
• (Insertion Order, Elements are stored by index, Duplicates are allowed, Null element is
allowed)
ArrayList
ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays
are of a fixed length. After arrays are created, they cannot grow or shrink, which means
that you must know in advance how many elements an array will hold. But, sometimes,
you may not know until run time precisely how large of an array you need. To handle this
situation, the collections framework defines ArrayList.
Creation of Arraylist:
ArrayList name_of_the _arraylist=new ArrayList();
Eg:
ArrayList al=new ArrayList();
11. Array ArrayList
Size of an array is fixed because, you
need to provide the size when creating
an array
Size of an ArrayList is growable, So no
need to specify size
When array of size ‘n’ with m
elements, then repeat For loop n times
to access m elements, so that (n-m)
times loop will be repeated
unnecessarily.
Using Iterator, we can access only the
available elements, So no waste of
time.
Exception is possible in case m > n No Exception problem
Retrieval is faster.
12. Array ArrayList
Object o[ ] = new Object[10]; ArrayList al = new ArrayList();
o[0] = new String(“hello”); al.add(new String("Srinivas"));
o[1] = new Integer(99); al.add(new Student(99))
o[2] = new Student[10, “var”]; al.add(new Student(or ,”99”))
for (i = 0; I < o.length; i++)
{
System.out.println(o[i]);
}
Iterator i = al.iterator();
while (i.hasNext())
{
System.out.println(i.next());
}
15. • import java.util.*;
• public class ArrayListTest2 {
• public static void main(String[] args) {
• ArrayList al = new ArrayList(); al.add(new
Integer(99));System.out.println(al);al.add("Srinivas");al.add("hari@hari.com");
• System.out.println(al); System.out.println(al.size()); System.out.println(al.isEmpty());
• // using toArray() method
• System.out.println("using toArray()");
• int len= al.size();
• Object[] o = new Object[len];
• o = al.toArray();
• for (int i = 0; i < o.length; i++) {
• System.out.println(o[i]);
• }
• // using Iterators
• System.out.println("using Iterators ");
• Iterator iter = al.iterator();
• while(iter.hasNext()){
• System.out.println(iter.next());
• }
• // using ListIterator
• System.out.println("using ListIterator");
• ListIterator liter = al.listIterator();
• while (liter.hasNext())
• {System.out.println(liter.next());}
• System.out.println("Using Previous(Print in reverse order)");
• while(liter.hasPrevious())
• {System.out.println(liter.previous());}
16. • // using ListIterator SET method Assigns obj to the current element
• System.out.println("using ListIterator");
• ListIterator liter = al.listIterator();
• while (liter.hasNext())
• {
• Object element = liter.next();
• liter.set(element + "+");
• }
• System.out.println("Modified contents" );
• Iterator it1 = al.iterator();
• while(it1.hasNext()) {
• Object element = it1.next();
• System.out.println(element+ "");
• }
• System.out.println("Using Previous(Print in reverse order)");
• while(liter.hasPrevious())
• {
• System.out.println(liter.previous());
• }
• // toArray
• System.out.println("2nd to array");
• Object[] o1 = al.toArray();
• for (int i1 = 0; i1<o1.length; i1++) {
• System.out.println(o1[i1]);
• }
• }
• }
17. Vector
• A Vector is basically the same as an ArrayList,
• Vector() methods are synchronized for thread safety.
• package com.jft.collections;
• import java.util.Enumeration; import java.util.Iterator; import java.util.Vector;
• public class VectorTest {
• public static void main(String[] args) {
• Vector v = new Vector();
• System.out.println(v);
• System.out.println(v.size());
• System.out.println(v.capacity());
• v.addElement("A");
• v.addElement("B");
• v.add("C");
• v.add("D");
• System.out.println(v);
• Enumeration e = v.elements();
• while (e.hasMoreElements()) {
• String str = e.nextElement().toString();
• System.out.println(str);
• }
• Iterator i = v.iterator();
• while (i.hasNext()){
• String str = i.next().toString();
• System.out.println(str);
• }}}
18. Differences
ArrayList Vector
Not Synchronized Synchronized
Iterator (To retrieve values) ListIterator(Superclass of Iterator)
Forward only (Iterate over a collection and
get values)
Both Forward & Reverse
Cant add elements to collection& Cant get
index (element)
Can add
Cant replace existing objects with new
object
Can replace using
while (liter.hasNext()) {
Object element = litr.next();
reference.set (element +” + ”) }
Iterator Enumeration
It is a collection framework interface Legacy (old) interface
Can also Remove elements Can only read elements
To access elements of AL, Vector, LL,
HS,TS, LHS
To access elements of vector only
19. * Array, ArrayList, Vector – Elements stored in indexing notation size by size
• While using indexing notation, the following error will occur:
- Inserting & Deleting element at specified index is time consuming.
- Solve this problem by using LinkedList – Elements will be stored in different memory
Locations and will be linked with address, such that insertion or deletion is faster.
LinkedList
- It provides a linked-list data structure.
- A LinkedList List is ordered by index position, like ArrayList, except that the elements are
doubly-linked to one another.
- This linkage gives you new methods beyond what you get from the List interface) for adding and
removing from the beginning or end, which makes it an easy choice for implementing a stack or
queue.
LinkedList l1=new LinkedList();
2 new methods in LinkedList:
void addFirst(Object obj)
void addLast(Object obj)
21. • public class Person {
• String name;
• int age;
• public Person(String n , int a) {
• name = n;
• age = a;
• }
• public String getName() {
• return name;
• }
• public void setName(String name) {
• this.name = name;
• }
• public int getAge() {
• return age;
• }
• public void setAge(int age) {
• this.age = age;
• }
• @Override
• public String toString() {
• return "name= "+name + " age= "+age;
• }
• /*boolean equals(Person p){
• if(this.name.equals(p.name)&& this.age == p.age){
• return true;
• }
• return false;
• }*/
• }
22. • package com.jft.collections;
• import java.util.ArrayList;
• import java.util.LinkedList;
• public class LinkedListDemo1 {
• public static void main(String[] args) {
• Person p1 = new Person("Allan",20);
• Person p2 = new Person("Robert",20);
• Person p3 = new Person("John",20);
• Person p4 = new Person("Hellen",20);
• Person p5 = new Person("Elen",20);
• Person p6 = new Person("Daisy",20);
• LinkedList l1 = new LinkedList();
• l1.add(p1);
• l1.add(p2);
• l1.add(p3);
• l1.add(p4);
• l1.add(p5);
• l1.add(null);
• l1.add(null);
• System.out.println(l1);
• //remove at specific index
• l1.remove(0);
• System.out.println(l1);
• //size
• System.out.println(l1.size());
• int i = l1.indexOf(p3);
• System.out.println(i);
• System.out.println(l1);
• l1.set(2, p6);
• System.out.println(l1);
• System.out.println("Is Person Daisy Available?"+l1.contains(p6));
23. • Object a[] = l1.toArray();
• for (i=0;i<a.length;i++){
• System.out.print(a[i]);
• }
• //Linked List Specific methods
• Person p7= new Person("Peter",20);
• Person p8= new Person("Tom",20);
• l1.addFirst(p7);
• l1.addLast(p8);
• System.out.println();
• System.out.println(l1);
• Object o1 = l1.getFirst();
• Object o2 = l1.getLast();
• System.out.println(o1);
• System.out.println(o2);
• l1.removeFirst();
• l1.removeLast();
• System.out.println(l1);
• /**/
• l1.clear();
• System.out.println(l1);
• }
• }
24. Differences
ArrayList LinkedList
Elements will be stored side by side with
indexing notation
Elements will be stored randomly
Elements will be accessed sequentially Elements will be accessed randomly
because it is implementing random access
marker interface
Insertion & Deletion are difficult Insertion & Deletion are easier
Uses less memory than LL Uses more memory in order to store
address
25. Set Interface
- A Set cares about uniqueness—it doesn’t allow duplicates. Therefore, the add( )
method returns false if an attempt is made to add duplicate elements to a set.
HashSet
- A HashSet is an unsorted, unordered Set.
- It uses the hashcode of the object being inserted, so the more efficient your
hashCode() implementation the better access performance you’ll get.
- Use this class when you want a collection with no duplicates and you don’t care
about order when you iterate through it.
- one null element allowed.
Eg:
HashSet hs = new HashSet();
// add elements to the hash set
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");
Output: [c,d,a,e.b,f]
27. LinkedHashSet
- A LinkedHashSet is an ordered version of HashSet that maintains a doubly-linked
List across all elements.
- Use this class instead of HashSet when you care about the iteration order; when
you iterate though a HashSet the order is unpredictable, while a LinkedHashSet lets
you iterate through the elements in the order in which they were inserted.
- Optionally, you can construct a LinkedHashSet so that it maintains the order in
which elements were last accessed, rather than the order in which elements were
inserted.
- one null element allowed.
- The output of the above code will be;
[B, A, D, E, C, F]
29. TreeSet
- TreeSet provides an implementation of the Set interface that uses a tree
for storage.
- Objects are stored in sorted, ascending order.
- Access and retrieval times are quite fast, which makes TreeSet an
excellent choice when storing large amounts of sorted information that must
be found quickly.
- null gives exception at run time, so null is not allowed.
Application: useful for storing project-management information.
31. Map Interface
• A map is an object that stores associations between keys and values, or
key/value pairs. Given a key, you can find its value.
- A Map cares about unique identifiers.
- Map maps a unique key (the ID) to a specific value, where both the key
and the value are of course objects.
- The keys must be unique, but the values may be duplicated.
- Some maps can accept a null key and null values, others cannot.
• Interface:
– Map.Entry Describes an element (a key/value pair) in a map. This is an inner
class of Map.
• entrySet( ) - returns a Set that contains the elements in the map
• keySet() - obtains a collection-view of the keys.
• values( ) - obtains a collection-view of the values.
• AbstractMap is a superclass for all concrete map implementations
32. • put() - Associates the specified value with the specified key in this map
• get() – Returns the value to which the specified key is mapped in this identity hash
map
• putAll() - Copies all of the mappings from the specified map to this map.
– These mappings will replace any mappings that this map had for any of the keys
currently in the specified map
• getkey() - Returns the key corresponding to this entry.
• getvalue() - Returns the value corresponding to this entry
33. HashMap
- The HashMap class uses a hash table to implement the Map interface.
- This allows the execution time of basic operations, such as get( ) & put( ),
to remain constant even for large sets.
- No Iteration order.
- Allows null
HashMap hm = new HashMap();
// Put elements to the map
hm.put("John Doe", new Double(3434.34));
hm.put("Tom Smith", new Double(123.22));
hm.put("Jane Baker", new Double(1378.00));
hm.put("Todd Hall", new Double(99.22));
hm.put("Ralph Smith", new Double(-19.08));
34. HashTable (no null)
- Hashtable is the synchronized counterpart to HashMap.
- stores key/value pairs in a hash table
• specify an object that is used as a key, and the value that you want linked to
that key.
• The key is then hashed, and the resulting hash code is used as the index at
which the value is stored within the table.
LinkedHashMap
- Like its Set counterpart, LinkedHashSet, the LinkedHashMap collection
maintains insertion order (or, optionally, access order or Iteration order)
- It will be somewhat slower than HashMap for adding and removing
elements.
TreeMap
- TreeMap is a sorted Map.
• Application: TreeMap would make an excellent collection to hold the
directory structure of a set of files
38. Differences
HashMap Hashtable
Accessible in collection framework Legacy class
Not synchronized Synchronized
Allows null keys & null values Doesn’t allow null keys & null values
HashMap TreeMap
Unordered Sorted & Ordered
Allows null keys & null values Doesn’t allow null keys & null values
Allows different types of keys Allows similar types of keys
39. Comparators
• Comparator interface defines two methods: compare( ) and equals( )
• A comparator object is capable of comparing two different objects.
• The class is not comparing its instances, but some other class’s instances.
• This comparator class must implement the java.lang.Comparator interface
• It implements the compare( ) method - Compares its two arguments for order.
• This method compares o1 and o2 objects.
• Returned int value has the following meanings.
• positive – o1 is greater than o2
• zero – o1 equals to o2
• negative – o1 is less than o1
• // compareTo() - Compares two strings lexicographically.
41. • class Employee{
• private int age;
• private String name;
• public void setAge(int age){
• this.age=age;}
• public int getAge(){
• return this.age;}
• public void setName(String name){
• this.name=name;}
• public String getName(){
• return this.name;} }
• class AgeComparator implements Comparator{
• public int compare(Object emp1, Object emp2){
• //parameter are of type Object, so we have to downcast it to Employee objects
• int emp1Age = ( (Employee) emp1).getAge();
• int emp2Age = ( (Employee) emp2).getAge();
• if( emp1Age > emp2Age )
• return 1;
• else if( emp1Age < emp2Age )
• return -1;
• else
• return 0;
• }}
42. • class NameComparator implements Comparator{
• public int compare(Object emp1, Object emp2){
• //parameter are of type Object, so we have to downcast it to Employee objects
• String emp1Name = ( (Employee) emp1 ).getName();
• String emp2Name = ( (Employee) emp2 ).getName();
• //uses compareTo method of String class to compare names of the employee
• return emp1Name.compareTo(emp2Name);
• }}
• public class JavaComparatorExample{
• public static void main(String args[]){
• /*Employee array which will hold employees */
• Employee employee[] = new Employee[2];
• //set different attributes of the individual employee.
• employee[0] = new Employee();
• employee[0].setAge(40);
• employee[0].setName("Joe");
• employee[1] = new Employee();
• employee[1].setAge(20);
• employee[1].setName("Mark");
• System.out.println("Order of employee before sorting is");
• //print array as is.
• for(int i=0; i < employee.length; i++){
• System.out.println( "Employee " + (i+1) + " name :: " + employee[i].getName() + ", Age :: " +
employee[i].getAge());
• }
43. • /*Sort method of the Arrays class sorts the given array.
• Signature of the sort method is,
• static void sort(Object[] object, Comparator comparator)
• IMPORTANT: All methods defined by Arrays class are static.
• Arrays class serve as a utility class. */
• /*Sorting array on the basis of employee age by passing AgeComparator */
• //Arrays.sort(employee, new AgeComparator());
• Arrays.sort(employee, new AgeComparator());
• System.out.println("nnOrder of employee after sorting by employee age is");
• for(int i=0; i < employee.length; i++){
• System.out.println( "Employee " + (i+1) + " name :: " + employee[i].getName() + ",
Age :: " + employee[i].getAge());
• }
• /* Sorting array on the basis of employee Name by passing NameComparator */
• Arrays.sort(employee, new NameComparator());
• System.out.println("nnOrder of employee after sorting by employee name is");
• for(int i=0; i < employee.length; i++){
• System.out.println( "Employee " + (i+1) + " name :: " + employee[i].getName() + ",
Age :: " + employee[i].getAge()); }}}