generics - Why doesn't Java iterator constructor signature has iterator type? -


This can be just a question on the signature layout of the Java Itater constructor.

Iterator type must be specified on class definition (an abstract type T or something as in the form); Thus, why its related manufacturer Public GunmenIterator (list list) does not contain the T iterator type? However, generally the normal type of T is used in the iterator, is it an alternative to match with other methods?

  Public Squares GunmenIterator & lt; T & gt; Uses the IETATOR & lt; T & gt; {Private list & lt; T & gt; List; Private Iterator & lt; T & gt; ITER; Public GunmenIterator (list & lt; T & gt; list) {this.list = list; This.iter = list.iterator (); } Public static zero major (string [] args) {Eitreter & lt; Integer & gt; Gunchainers = new gunfighter iterator & lt; Integer & gt; (Gunman); }}  

As shown above, iterator type & lt; Integer & gt; must be present in the beginning (otherwise, compiler warnings will occur). However, in the signature of the constructor, & lt; T & gt; can not be added.

You can enter & lt; T & gt; is not required because the constructor class GunmenIterator & lt; T & gt; is a constructor. It is built in such a way that its constructor is a gunman iterator & lt; T & gt; creates.

& lt; T & gt; It would be useless to repeat a producer always makes an example of that class whose part is this.


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 -