2

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
  • 1
    What methods of LinkedList do you use that aren't in List? Commented May 17, 2010 at 2:05
  • 2
    What style checker program are you using? Are you sure that the problem is not that they are not with generics arguments? Commented May 17, 2010 at 2:07
  • 1
    It's going to be hard to answer this question without seeing at least part of the code, knowing which type of checker program you use and what you use it for. Please try to be more specific (more data rarely hurts) Commented May 17, 2010 at 3:04
  • ignore the style checker, or tell the style checker developers that LinkedList has unique methods (addFirst,addLast, etc) that are commonly used, and should not be flagged. Commented May 18, 2010 at 3:02

2 Answers 2

4

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 :)

Sign up to request clarification or add additional context in comments.

Comments

-1

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.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.