PCC CS - 503
GROUP NUMBER:13
Generic types
&
Collections GUIs
OUR MEMBERS
AYUSH DEY
ANIKET SINGH
11500219041
DEBJIT KAR
11500219031 11500219033
11500219036
AVIRUP PAL
CONCLUSION
COLLECTION
FRAMEWORK
GENERICS
Full discussion
about the generics
01
Collection Framework
hierarchy,advantages
and much more
02
TABLE OF CONTENTS
03
GENERICS
DEFINITION
TYPES & ADVANTAGES
01
Definition: “A generic type is a
generic class or interface that is
parameterized over types.”
GENERICS in JAVA
Java Generics is a set of related
methods or a set of similar types.
Generics allow types Integer, String,
or even user-defined types to be
passed as a parameter to classes,
methods, or interfaces. Generics are
mostly used by classes like HashSet
or HashMap.
● Java Generics does not
support sub-typing.
● You cannot create generic
arrays in Java Generics.
Advantages Constraints
Generic method:
Generic Java method takes a parameter and
returns some value after performing a task. It is
exactly like a normal function, however, a
generic method has type parameters which are
cited by actual type. This allows the generic
method to be used in a more general way. The
compiler takes care of the type of safety which
enables programmers to code easily since they
do not have to perform long, individual type
castings.
Types Of Generics in JAVA
Generic classes:
A generic class is implemented exactly like a
non-generic class. The only difference is that
it contains a type parameter section. There
can be more than one type of parameter,
separated by a comma. The classes, which
accept one or more parameters, are known
as parameterized classes or parameterized
types.
This example shows how to
print different types of arrays
using the single Generic
method:
Single Generic Method
This example show how to
define a generic class.
Generic Class
COLLECTION
FRAMEWORK
What is collection
framework and it types
And much more
02
● A Collection (also known as
Container) is an object that
contains a group of objects
treated as single unit
● Any type of objects can be
stored, retrieved and
manipulated as elements of
collection
What is a Collection
Collections Framework is an unified architecture for managing
collection
MAIN PARTS OF COLLECTION FRAMEWORK:
● Interfaces
○ Core interfaces defining common functionality exhibited by collections
● Implementations
○ Concrete classes of the core interface providing data structures
● Operations
○ Methods that perform various operations on collections
Collection Framework Overview
Advantages of the Collection
Framework
Reduces
performance Effort
Increases
performance
Foster software
rescue
Provides
interoperability
between unrelated
APIis
Reduces the
effort to learn
APIs
Reduces the effort
required to design
and implement APIs
An iterator is an object used to mark a
position in a collection of data and to
move from item to item within the
collection
SYNTAX:
Iterator <variable> = <CollectionObject>.iterator();
ITERATOR
COLLECTIONS FRAMEWORKS
IMPLEMENTATIONS
SET LIST MAP
HashSet ArrayList HashMap
LinkedHashSet LinkedList LinkedHashMap
TreeSet Vector Hashtable
Tree Map
Collection Hierarchy in JAVA
LIST: List of things(classes that implement list)
COLLECTION IMPLEMENTATIONS
Set:Unique things(classes that implement set)
Map: Things with unique ID(classes that implement map)
A list cares about the index
LIST
ARRAY LIST
VECTOR
LINKED LIST
A Set cares about uniqueness, it doesn't allows duplicates
SET
HASH SET
LINKED HASH SETS
TREE SET
MAP
HASH MAP
HASH TABLE
LINKED HASH MAP
TREE MAP
CONCLUSION 03
Why Use Generics?
In a nutshell, generics enable types
(classes and interfaces) to be parameters
when defining classes, interfaces and
methods. Much like the more familiar
formal parameters used in method
declarations, type parameters provide a
way for you to re-use the same code with
different inputs.
CONCLUSION
Why Use Collection in JAVA?
The Java Collections Framework provides
the following benefits: Reduces
programming effort: By providing useful
data structures and algorithms, the
Collections Framework frees you to
concentrate on the important parts of your
program rather than on the low-level
"plumbing" required to make it work.
Presented by :
GROUP -13
MR. KAR
MR.DEY
MR.SINGH
MR.PAL
Thanks You

Generic types and collections GUIs.pptx

  • 1.
    PCC CS -503 GROUP NUMBER:13 Generic types & Collections GUIs
  • 2.
    OUR MEMBERS AYUSH DEY ANIKETSINGH 11500219041 DEBJIT KAR 11500219031 11500219033 11500219036 AVIRUP PAL
  • 3.
    CONCLUSION COLLECTION FRAMEWORK GENERICS Full discussion about thegenerics 01 Collection Framework hierarchy,advantages and much more 02 TABLE OF CONTENTS 03
  • 4.
  • 5.
    Definition: “A generictype is a generic class or interface that is parameterized over types.” GENERICS in JAVA Java Generics is a set of related methods or a set of similar types. Generics allow types Integer, String, or even user-defined types to be passed as a parameter to classes, methods, or interfaces. Generics are mostly used by classes like HashSet or HashMap.
  • 6.
    ● Java Genericsdoes not support sub-typing. ● You cannot create generic arrays in Java Generics. Advantages Constraints
  • 7.
    Generic method: Generic Javamethod takes a parameter and returns some value after performing a task. It is exactly like a normal function, however, a generic method has type parameters which are cited by actual type. This allows the generic method to be used in a more general way. The compiler takes care of the type of safety which enables programmers to code easily since they do not have to perform long, individual type castings. Types Of Generics in JAVA Generic classes: A generic class is implemented exactly like a non-generic class. The only difference is that it contains a type parameter section. There can be more than one type of parameter, separated by a comma. The classes, which accept one or more parameters, are known as parameterized classes or parameterized types.
  • 8.
    This example showshow to print different types of arrays using the single Generic method: Single Generic Method
  • 9.
    This example showhow to define a generic class. Generic Class
  • 10.
  • 11.
    ● A Collection(also known as Container) is an object that contains a group of objects treated as single unit ● Any type of objects can be stored, retrieved and manipulated as elements of collection What is a Collection
  • 12.
    Collections Framework isan unified architecture for managing collection MAIN PARTS OF COLLECTION FRAMEWORK: ● Interfaces ○ Core interfaces defining common functionality exhibited by collections ● Implementations ○ Concrete classes of the core interface providing data structures ● Operations ○ Methods that perform various operations on collections Collection Framework Overview
  • 13.
    Advantages of theCollection Framework Reduces performance Effort Increases performance Foster software rescue Provides interoperability between unrelated APIis Reduces the effort to learn APIs Reduces the effort required to design and implement APIs
  • 14.
    An iterator isan object used to mark a position in a collection of data and to move from item to item within the collection SYNTAX: Iterator <variable> = <CollectionObject>.iterator(); ITERATOR
  • 15.
    COLLECTIONS FRAMEWORKS IMPLEMENTATIONS SET LISTMAP HashSet ArrayList HashMap LinkedHashSet LinkedList LinkedHashMap TreeSet Vector Hashtable Tree Map
  • 16.
  • 17.
    LIST: List ofthings(classes that implement list) COLLECTION IMPLEMENTATIONS Set:Unique things(classes that implement set) Map: Things with unique ID(classes that implement map)
  • 18.
    A list caresabout the index LIST
  • 19.
  • 20.
  • 21.
  • 22.
    A Set caresabout uniqueness, it doesn't allows duplicates SET
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
    Why Use Generics? Ina nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. CONCLUSION Why Use Collection in JAVA? The Java Collections Framework provides the following benefits: Reduces programming effort: By providing useful data structures and algorithms, the Collections Framework frees you to concentrate on the important parts of your program rather than on the low-level "plumbing" required to make it work.
  • 33.
    Presented by : GROUP-13 MR. KAR MR.DEY MR.SINGH MR.PAL Thanks You