Wednesday 15 January 2014

java - Type parameters in a method -


I would like to write a common method, which takes the set with integer or string values. The method should be determined and returned to the list which includes the set of common types. I am quite new to Generic and have a problem with the specified code below. The compiler does not like T in the method signing. What's the problem? Private listings & lt; Set & lt; T & gt; & Gt; CreateChunkSet (Set & lt; T & gt; Set) {Set & lt; T & gt; Set = new hashet & lt; T & gt; (); Return set; Declaration of the law:

  Private & LT; T & gt; & Lt; Set up & lt; T & gt; & Gt;   

which is a set with integer or string values ​​

A < Code> set & lt; T & gt; In , only one type of element can be type of T , either integer or string not both.

No comments:

Post a Comment