java - How is generic information used by the compiler if generic static methods are called? -


I have a question about the general type. I have written my own Iterator type and if I repeat it again If nothing is there, then want to return empty repeaters.

The following code works,

  @Override public iterator & lt; MyType & gt; Iterator () (last Iterator & lt; methype & gt; IARAR = collection. Return calculation & gt; New MiITATOR (): ITER;}  

However, it does not work , If written in a row like this:

  @ override public iterator  iterator () {return calculation> New MyITter (): collection exempt ();}  

I get an error and type to solve it:

  @ override public Iterator & lt; MyType & Gt; iterator () {w} (Iterator & lt; MyType & gt;) (Count> New Miterator: Collection Executioner ());}  

This artist goes to an arbitrary warning, first There is no warning in the example.

When I move the artist from inside, it does not work either:

  @override public iterator & lt; MyType & gt; Iterator () {Return calculation> New Age Iterator (): (Iterator & Lt; MyType & gt;) Collection. And ();}  

My question is: why the compiler can not determine that follows right after the examples, but the first. Why does the 3rd edition work, but not in the last one? Variants are basically similar in my impressions.

If you want to work it out, use it syntax:

  Return Collection.  emptyIterator ();  

This is the way to give a stable method to normalize.

If you want to call then. Iterator & lt; Object & gt; which is incompatible with your return type.

You can not even be cast because Iterator & lt; MyType & gt; Does not expand iterator & lt; Object & gt; .


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -