• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit Testing?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm attempting to run some tests on a DoublyLinkedList class I have created. In order to do so, I'm creating an ArrayList to compare to the DoublyLinkedList. Here's my current method:



My DoublyLinkedList class extends AbstractList, but I am receiving the error: "cannot find symbol
symbol : class ArrayList
location: class DoublyLinkedListTest"

I'm confused as to why I'm having trouble using an ArrayList here?

Thanks!
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you import java.util.ArrayList? Also, what does any of this have to do with your subject, "JUnit Testing?"?
 
Marshal
Posts: 8857
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this method is meant to be a test method, don't use such method name as DoublyLinkedListTest, it doesn't say anything useful about your test case.
Test method name should reveal its full intention, that could be even 20 words if needed.

Are you using JUnit testing framework? I don't see any annotation above the method.

Which Java version you use?
When you initialize you don't need to supply parameter type on the right hand side (bolded) ArrayList<String> test2 = new ArrayList<String>();.
Since Java 7 it is called diamond operator, so you can write just ArrayList<String> test2 = new ArrayList<>();

Please fix code indentation on line 4. That closing curly brace should be aligned with keyword public. Also, when you indenting your code, use 4 spaces for shifting.
Currently you have 2 spaces only, that could become tricky to read when the class gets bigger.

[edit] I just noticed it is not a method, but rather a class. Same as Junilu, please clarify what are you trying here. Thank you.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carly Griffin wrote:My DoublyLinkedList class extends AbstractList...


Hmmm. Doesn't sound right to me. Unless you have some sort of fast mechanism for random retrieval, it should probably extend AbstractSequentialList (←click), which is itself an extension of AbstractList; otherwise you're likely to have to write a lot more of the class yourself.

Java's own LinkedList (which is also double-linked) extends ASL.

Winston
reply
    Bookmark Topic Watch Topic
  • New Topic