LinkedList parameters in Java

I have created a program that contains linked lists that are passed in various ways. While this works fine in Java ... the style checker we should be using doesn't like

It says: Declaring variables, return values, or parameters of type 'LinkedList' is not allowed.

If I declare them as just a list, then I don't have access to the methods I want. What should I do?

+2


a source to share


2 answers


Declare it as Deque

(a different interface that it implements) or reconfigure your style checker. However, Deque

has some missing methods, not List

. Here's an excerpt from his Javadoc:

Unlike the interface List

, this interface does not provide support for indexed element access.



But I don't expect you to use them :)

+4


a source


If you are sure the value that goes into the style checker is LinkedList, then it sends the list to LinkedList, which gives you access to your methods.



-1


a source







All Articles