JDk1.5.0 Class<T> problem??

I have a small program:
===============

public class TestMe
{
        public TestMe() {}
        public static void print (Class<TestMe> cls)
        {
        }
        public static void main (String [] args)
        {
                print(ABC.class);
        }
}

class ABC extends TestMe
{
        public ABC() {}
}

==========================
It fails to compile due to the following reason:

TestMe.java:12: print(java.lang.Class<TestMe>) in TestMe cannot be applied to (java.lang.Class<ABC>)
                print(ABC.class);

Any Idea of solving this little problem?????
zollenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
shinobunConnect With a Mentor Commented:
Try this:

public static void print (Class<? extends TestMe> cls)
0
 
shinobunCommented:
0
 
hoomanvCommented:
Or leave the print method signature unchanged
But cast the class like this
print((Class<TestMe>) TestMe.class);
0
 
hoomanvCommented:
NO NO You want ABC, so my method is not correct
0
 
kannan_ekanathCommented:
To generalise, if a Banana extends Fruit. Then a Baseket of Banana does not extend Basket of Fruit. To understand this in an agile/easier way, refer these links,

http://www.agiledeveloper.com/articles/GenericsInJavaPartI.pdf
http://www.agiledeveloper.com/articles/GenericsInJavaPartII.pdf
0
All Courses

From novice to tech pro — start learning today.