• Post Reply Bookmark Topic Watch Topic
  • New Topic

LinkedList's methods does not appear  RSS feed

 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please, why could not get the getFirst() and getLast methods using the List and Collection interfaces?

bye bye

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The variable "lista" is of type List, but getFirst() and getLast() are only defined for LinkedList, so they're not accessible. Change your variable declaration to make lista a LinkedList, as in the commented-out line, and it should be fine.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see ItDoesntWorkIsUseless -- what happens? Do you get an error? At compile time? Run time?

Obviously Ernest is correct, but it's important to provide useful information with your questions! Thanks!
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes André, I agree with Ernest about java and David about forum rules.

Just remember one thing. When you do


You will only have access to List methods.
 
André Asantos
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, thanks a lot for answering my doubt...

bye bye,

André AS
São Paulo - Brazil
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try a castNote getFirst is specified in the Deque<E> interface, not List.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!