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: Java
Expertise: Intermediate
Oct 5, 2009



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

A Guide to Determine When You Need a Java Interface

You should create a Java interface if your needs meet either of the following scenarios:

  1. When you need plug-in capabilities to go with an interface option. As an example, consider a Java-based car racing video game. As shipped, it supports BMW and Audi cars, but I want third-party car providers to be able to create cars for this game. Because each car type should be able to react differently to user input and conditions, I created one interface with leftKey(), rightKey(), upKey(), and downKey() methods; every car should implement these methods.

    Now, for example, Mercedes could create a car that understands this interface implementation and provide it to me. When a race starts with this new car, my host application can execute without knowing the underlying object type (third-party Mercedes).

  2. You need a callback mechanism (function pointers in Java) for such things as a JDBC connection interface, Swing event listeners, or MOM.
Rajasekaran Kandhasamy
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