O'Reilly logo

Technical Java™: Developing Scientific and Engineering Applications by Grant Palmer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23. Generic Class Libraries

Consider the following common programming situation. You write an analysis method where part of the analysis is generic and part is specific to a given problem. As a good Java programmer, you don't want a different version of the method for every problem it might be used to solve. What you want is to write one generic version of the method that accepts the problem-specific information as an argument.

In C the answer would be to use a function pointer. As the name implies, it is a pointer to a generic function with a certain input parameter list. Java doesn't have function pointers, but you can do the same thing by using classes. A class can be defined to contain problem-specific information. An instance of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required