java - Abstract class or interface for translator objects on Android -


I want to summarize the translator service for the user. I have the idea of ​​doing this in two ways:

or interface with this method:

  public null translation (T basic, T1 source);  

Or an abstract class with the same method, with generic classes to use with both classes.

Its better, interface or intangible class witch?

How can I do this in Android with normal classes? Because the compiler says that

  symbol can not be solved  

I hope that I understand correctly Generic parameter should appear in the Interface (or Abstract Class) Declaration:

 

Public Interface Translator & lt; T, T1 & gt; {Public Zero Translation (T Basic, T1 Source); }

Whether an abstract class or an interface is more suitable, it depends on the fact that the interface (or sub-classes of the abstract class) can be seen as an implementation Is similar to the interface / abstract class or not. If the answer is yes, then an abstract class is appropriate.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -