Using Generic Methods like Templates?
I have taking about a year in c++ and am trying to learn java right now. I'm really confused about generics because it looks like templates in c++ to me. Here is a snippet of my code that wont work.
public static <T> void monsterMain(T monster)
{
monster.getStats();
}
There are 4 different data types that can be passed to this method. The function in the derived class getStats() works fine, I have tested it other places. The error I get is:
'cannot find symbol'
'symbol: method getStats()'
Each derived class has a redefined function getStats() so the calling data type shouldn't be an issue. Any help would be mucho appreciated.