tags:

views:

94

answers:

2

Hi there,

I created a program that contains linked lists that are passed various methods. While this works just fine in Java... a style checker program we have to use doesn't like it

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

If I declare them as simply List then I don't have access to the methods I want. What should I do?

+4  A: 

Either declare it as Deque (the other interface it implements) or reconfigure the style checker program. The Deque has however some missing methods as opposed to List. Here's an extract from its Javadoc:

Unlike the List interface, this interface does not provide support for indexed access to elements.

But I don't expect that you're using them :)

BalusC
A: 

If you are sure, the value which enters in to Style Checker Program is an LinkedList then cast the List to LinkedList which gives access to your methods.

Phani
The style checker isn't going to like that cast either.
Michael Borgwardt