java - What is the meaning of method having two diamond brackets in generics? -


What is the need to have two diamond brackets in one method, and if T is not a return type then why do we need it ?

Or is anything related to casting?

  Package Generic; Import java.util.ArrayList; Import java.util.list; Public category GenericMethodType {public & lt; T & gt; & Lt; T & gt; ToList (T [] parameters) {// some related to casting is t & lt; T & gt; List = New Arrestist & lt; & Gt; (); For (T: parameter) {list.add (t); } Return list; } Public static zero main (string [] args) {GenericMethodType gmt = new GenericMethodType (); System.out.println (gmt.toList (new integer [] {1,2,34,4}); }}  

  public & lt; T & gt; & Lt; T & gt; ToList (T [] parameters) ^ / / Introduction of general type T /  

This means that the name is a defined general type with the name T Strong> only for the scope of this method

More information:

< / Html>

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

android - how to get distance of 2 beacons and make a condtion base on that distance -

c# - WPF Expander overlay used in ItemsControl -