betweenGo

Java Method with Generic Return Type

by on Sep.01, 2008, under Java SE

To create a Java method with a generic return type one can write a method like this.

  protected static <T> T evaluateExpression(String tagName,
      String attributeName, String attributeValue,
      Class<T> expectedType, Tag tagRef,
      PageContext pageContext)

You can learn more at this Java Generics FAQ.

Share

Related posts:

  1. Covariant Return Types in Java
  2. Effective Java Collections
  3. Do Not Return From a Try Block
  4. Accessing the class from a static method which the class owns
  5. Accessing JavaBean’s Getters and Setters

:

Leave a Reply

 

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!