betweenGo

Java Method with Generic Return Type

by Frank Kim 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/Bookmark

Related posts:

  1. Covariant Return Types in Java
  2. Accessing the class from a static method which the class owns
  3. Effective Java Collections
  4. Do Not Return From a Try Block
  5. user-defined property type gotcha’s

:

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!