Subclassing generic type

When subclassing the generic type we can keep the generic type.

 
class Shape<T>{

}

class Rectangle<T>:Shape<T>{
  
}
  

Or we can close the generic type by replacing the generic type with a concrete type.

 
class Shape<T>
{

}

class Rectangle<int> : Shape<int>
{

}

Or we can add more generic parameters.

 
class Shape<T>{

}

class Rectangle<T,K>:Shape<T>{
  
}
  
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.