Search This Blog

Friday, February 8, 2013

Java generic methods; Java generic classes; Java static generic method

Java has a different syntax for generic methods, generic classes and static generic methods.

  • Java generic classes
public class ComboBoxDefinition<T extends Identifiable> extends AbstractFieldDefinition implements xxxx
{
    protected ComboBoxDefinition(BeanContainer<T> beanContainer)
    {
    }
}
  • Java generic methods
public class ComboBoxDefinition
{
    public void draw(List<? extends Control> controls) {
    }
}
  • Java static generic methods
public class SomeClass
{
     public static <T extends Identifiable> void create(BeanContainer<T> beanContainer) {
        
    }
}

1 comment:

  1. Very nice to read this problem solving blog.
    Thanks for sharing this info .
    As, statics should be used when you don't want to have varying behavior for different objects.

    http://efectivejava.blogspot.in/2013/08/when-to-use-static-members-in-java.html

    ReplyDelete

If you like this post, please leave a comment :)