Monday 15 June 2015

java - Why generic to object type-casting is implicit? -



java - Why generic to object type-casting is implicit? -

while converting non-generic class generic one, saw working :

public class testexception<t> { t t; object getobj(){ homecoming t; } }

when tried alter return-type object other string, had type cast :

string getobj(){ homecoming (string)t; }

why generic object type-casting implicit ? couldn't find implementation on java docs.

every class inherits object, t guaranteed implicitly convertible object.

java generics

No comments:

Post a Comment