aspose file tools*
The moose likes Java in General and the fly likes Abstract method in generic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Abstract method in generic" Watch "Abstract method in generic" New topic
Author

Abstract method in generic

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
Good day,

I trying to include a method for generic as follow, but the IDE complain about Can't resolved symbol "T"



Thank you for enlightenment!
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

http://docs.oracle.com/javase/tutorial/java/generics/types.html
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
Sorry James, I really dumb enough and can't figure out what is the problem on my code , appreciated your guidance
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Did you not read anything in the link I posted? Wow, you ain't going to get much help around here.

Hint: you haven't declared T.
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
Thanks James for the hint!

actually i did a method which doesn't required me to declare type in class(refer to code3), so i confuse when to use and when is not, and appreciated if you can help me to understand further.

I have done the code1, it seem good, thanks for enlighten me

Code 1:


Code2:



Code3:
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
Surely it’s without the <> in the ().
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
Thanks Cambell and James !

May i know why code3 doesn't required declare T in the class ?
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

T is declared in code snippet 3 (between the <>).
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
James,
Just curious why we can't do following since code3 can work without type declaration in class

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

In that example, you are not declaring T. The declaration does not go within the argument list.

This is what you want:

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 187
Thanks you for enlighten me !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract method in generic