|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Junior Member
Iscritto dal: Oct 2010
Messaggi: 10
|
[java] Problema utilizzando le interfacce in Java
Ho un metodo scritto in questo modo:
Codice PHP:
Dove RulesVariablesInterface è un'interfaccia. Ho la seguente classe che implementa l'interfaccia: Codice PHP:
Codice PHP:
The method executeListFact(List<RulesVariablesInterface>) in the type Executor is not applicable for the arguments (List<RulesVarIndicatoreEvento>) Qualcuno sa aiutarmi? Grazie mille Ultima modifica di zar1978 : 16-03-2011 alle 08:09. |
![]() |
![]() |
![]() |
#2 |
Member
Iscritto dal: Jul 2004
Messaggi: 182
|
Il parametro formale di compute è una lista di RulesVarIndicatoreEvento, non gli puoi passare una lista di
RulesVariablesInterface, anche se è l'interfaccia implementata, per la classe degli elementi delle liste non puoi fare come per gli oggetti(es. RulesVariablesInterface x=new RulesVarIndicatoreEvento() ) |
![]() |
![]() |
![]() |
#3 | |
Junior Member
Iscritto dal: Oct 2010
Messaggi: 10
|
Quote:
Codice PHP:
|
|
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Puoi rendere generici anche i metodi.
Inoltre, i tipi parametrici possono essere dichiarati specificando un bound. Ad esempio, nel tuo caso, puoi parametrizzare il metodo executeListFact con un type parameter "T" che estenda RulesVariablesInterface. Ecco come sarebbe la firma di executeListFact: Codice:
public synchronized <T extends RulesVariablesInterface> void executeListFact(List<T> listRV) { ... }
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) Ultima modifica di banryu79 : 16-03-2011 alle 09:02. |
![]() |
![]() |
![]() |
#5 | |
Junior Member
Iscritto dal: Oct 2010
Messaggi: 10
|
Quote:
Grazie mille |
|
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 11:58.