• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract method in generic

 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry James, I really dumb enough and can't figure out what is the problem on my code , appreciated your guidance
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49367
62
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Surely it’s without the <> in the ().
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cambell and James !

May i know why code3 doesn't required declare T in the class ?
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T is declared in code snippet 3 (between the <>).
 
Nakataa Kokuyo
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
Just curious why we can't do following since code3 can work without type declaration in class

 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you for enlighten me !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic