Results 1 to 9 of 9

What is Generics in java

This is a discussion on What is Generics in java within the Programming forums, part of the Web Designing & Development category; Describe generics of java....

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    8

    Default What is Generics in java

    Describe generics of java.

  2. #2
    Senior Member
    Join Date
    Jun 2015
    Posts
    940

    Default Re: What is Generics in java

    Generics are a facility of generic programming that were added to theJava programming language in 2004 within J2SE 5.0. They allow "a type or method to operate on objects of various types while providing compile-time type safety." This feature specifies the type of objects stored in a Java Collection.

  3. #3
    Senior Member
    Join Date
    Jun 2014
    Location
    United Kingdom
    Posts
    150

    Default Re: What is Generics in java

    In my opinion the java generics programming is introduced in J2SE 5 to deal with the type-safe objects.

  4. #4
    Senior Member
    Join Date
    Jan 2016
    Posts
    145

    Default Re: What is Generics in java

    Generics in java were added to java in 2004.They allow a type or method to operate on objects of various types.
    Advantages of generics in java:

    • Type Safety
    • Type casting is not required
    • Compile type checking

  5. #5
    Senior Member
    Join Date
    Jan 2012
    Posts
    781

    Default Re: What is Generics in java

    A generic type is a generic class or interface that is parameterized over types. The following Box class will be modified to demonstrate the concept.

  6. #6
    Member charlottegracie's Avatar
    Join Date
    Jan 2017
    Posts
    95

    Default Re: What is Generics in java

    Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

  7. #7
    Member
    Join Date
    Dec 2016
    Posts
    94

    Default Re: What is Generics in java

    Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods, or with a single class declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

  8. #8
    Member charlottegracie's Avatar
    Join Date
    Jan 2017
    Posts
    95

    Default Re: What is Generics in java

    The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects.Before generics, we can store any type of objects in collection i.e. non-generic. Now generics, forces the java programmer to store specific type of objects.
    Advantages of generics in java:


    • Type Safety
    • Type casting is not required
    • Compile type checking

  9. #9
    Junior Member
    Join Date
    Jun 2016
    Posts
    16

    Default Re: What is Generics in java

    The Java Generics programming is introduced in J2SE 5 to deal with type-safe objects. It is widely used today.