Parametric polymorphism

Parametric polymorphism is an approach in different programming language to make a language more expressive, while as yet keeping up full static write well being. Utilizing parametric polymorphism, a capacity or an information compose can be composed blandly so it can deal with values indistinguishably without relying upon their sort.

Explanation

Parametric polymorphism is the center guideline behind non specific programming dialects and structures. It empowers the formation of nonexclusive capacities and information writes that work on values, paying little mind to information compose. 

For instance, if a programming capacity works on two distinct qualities, the qualities might be connected, despite the fact that they don't have similar information composes. An illustration is joining a rundown of whole numbers with a drifting point esteem. 

Ada, Haskell, Visual Prolog, Scala, Java and C# are modifying dialects that help parametric polymorphism.

Example

public interface Vehicle
{
  public String Run();
}

public class Bus implements Vehicle
{
  public String Run();
  {
    return "Model no 1127";
  }
}

public class Car implements Vehicle
{
  public String Run();
  {
    return "Model no 1227";
  }
}

import java.util.*;

public class PolymorphismExample
{
  public static void main(String[] args)
  {
    Collection<Vehicle> Vehicle= new ArrayList<Vehicle>();
    Vehicle.add(new Bus());
    Vehicle.add(new Car());
    for (Vehicle a : Vehicle)
    {
      System.out.println(a.Run());
    }
  }
}

                                                                                                                                        Previous Lecture
Next lecture