Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Design Patterns
Expertise: Beginner
May 31, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Templates in java

Any suggestions on a good way to implement templates in java?

The normal way to implement template behavior in Java is to create an interface defining the common behavior that is being abstracted. Every class that would normally would be instantiated as a template in C++, would have to implement this interface in Java. A good example of this is the java.lang.Comparable interface in JDK 1.2. You can write a single sort method to sort any object implementing the Comparable interface, rather than writing N different sorts. However, you will find that this approach is not sufficient to achieve all of the benefits of C++ templates. You may consider doing a search on the web for an experimental Java compiler called Pizza, which implements extra functionality like templates.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date