cmbhatt
Originally posted by nik arora:
Hi chandra,
What exactly the below statement states can you explain me please?
public static<E extends CharSequence> Collection<? extends CharSequence> getLongWords(Collection<E> coll)
cmbhatt
Originally posted by nik arora:
Hi chandra,
I didnt get this statement
1- Before return clause, you declare the parameterized type, what you have "E".
"E" has a bound that it must be CharSequence or any class that implements CharSequence interface (here for extending and implementing extends is used only).
cmbhatt
cmbhatt
Originally posted by nik arora:
Hi Chandra,
In the below statement type is: <E extends CharSequence> so my doubt the arguments for the method will be only that extends CharSequence. Am i right or wrong.
public static <E extends CharSequence> Collection<? extends CharSequence> getLongWords(Collection<E> coll)
cmbhatt
Also just want to confirm that the following wont be correct becuase we cannot use "?" in declaration.
public static Collection<? extends CharSequence> getLongWords(<? extends CharSequence> coll)
cmbhatt
Originally posted by Megha,
public static <E extends CharSequence> Collection<E> getLongWords(Collection<E> coll)
--------------------------------------------------------------------------------
In this case I have to return String, I cant return StringBuffer, bcoz my E went in as String and what I return is E so it should also be E, as opposed to the Bounded wildcard which would have allowed some flexiblity. In this case also I can't add anything to the returned collection as word "super" is not used here too.
Let me know what you say?
cmbhatt
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |