, ++- Java. ++ . , ... Java... ... .
, , , Java. , , , ++.
http://www.jquantlib.org/index.php/Using_TypeTokens_to_retrieve_generic_parameters
, , : Java, , , , .
, . , , .
Ok. .
Java :
1. ( )
2. javac , , ;
3. , №2, .
, Scala, №2, , , , .
"" Java ( Scala), - :
, - ++:
template<Base>
public class Extended : Base { ... }
Java :
public interface Virtual<T> { ... }
public class Extended<B> implements Virtual<B> { ... }
OK. , Extended, ?
Extended extended = new Extended<Base>() { }
.. Extended. . .
OK. Extended, Virtual.
Note that during compilation, javac can check types for you, for example, in the following example:
public interface Virtual<Base> {
public List<Base> getList();
}
public class Extended<Base> implements Virtual<Base> {
@Override
public List<Base> getList() {
return null;
}
}
Well ... despite all the efforts to implement it, in the end we do poorly that an excellent compiler, such as scalac, is much better than us, in particular, it does its job at compile time.
I hope this helps ... if you haven’t embarrassed you yet!
source
share