Maruthi Krishna has Published 951 Articles

What is need of introducing Generics, when Arrays already present in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 08:30:28

63 Views

Arrays in Java are used to store homogeneous datatypes, where generics allow users to dynamically choose the type (class) that a method, constructor of a class accepts, dynamically.By defining a class generic you are making it type-safe i.e. it can act up on any datatype. To understand generics let us ... Read More

Is it mandatory to use T for type-parameter, while defining Generics classes/methods in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 08:26:15

526 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Where exactly Type-Parameter need to be specified, while declaring generic method in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 08:22:05

206 Views

Similar to generic classes you can also define generic methods in Java. These methods use their own type parameters. Just like local variables, the scope of the type parameters of the methods lies within the method.While defining a generic method you need to specify the type parameter within the angle ... Read More

What are raw types in generics in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 08:15:30

443 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Can we have multiple type parameters in generic methods in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 08:05:18

9K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

What are generic methods in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 07:52:25

606 Views

Similar to generic classes you can also define generic methods in Java. These methods use their own type parameters. Just like local variables, the scope of the type parameters of the methods lies within the method.While defining a generic method you need to specify the type parameter within the angle ... Read More

Can we throw an object of generic class in java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 07:48:27

505 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Why can't Java generics be used for static methods?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 07:42:47

3K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Passing primitive values while instantiating a parameterized type (generic) in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 07:36:48

426 Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Can you create an array of Generics type in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Sep-2019 07:33:09

1K+ Views

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class ... Read More

Advertisements