CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Generics

Java – How to impose constraints on Generics in Java?

In our previous article, we discussed generics in Java. There are a few constraints that we can impose while working with Generics using extends and super keywords. The ‘extends’ keyword with respect to class Let’s create the Demo<T> class using extends keyword. class Demo<T extends Number> {        T value; } This implies that the class […]

Java – How to use Generics in Java?

Java is a type-safe language. In the sense, in Java, it is required to specify the data type of the variable or the method argument while declaring it. For instance, see the examples below: int var = 5;   //  type of the variable is int void show(String arg){}   // type of the argument arg is […]

Scroll to top