This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Filling Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Filling Array" Watch "Filling Array" New topic
Author

Filling Array

Teri Fisher
Ranch Hand

Joined: Jan 07, 2008
Posts: 52
I am trying to write the test code in Main and don't understand how to fill my array with the methods we are supposed to use. Thanks in advance.

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

That's 465 lines of code!

Can you focus on a few lines and tell us where exactly you're having trouble?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Teri Fisher
Ranch Hand

Joined: Jan 07, 2008
Posts: 52
Sorry, I guess I wanted to show what I had to work with, I wanted to put in an add method but we are supposed to use what is in our outline.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18501
    
  40

I wanted to put in an add method but we are supposed to use what is in our outline.


Basically, you are writing test code. If you modify your class with special methods just for your test code, aren't you just wasting a testing opportunity?

Your class seems to have two add methods that add individual elements -- addBefore and addAfter. Do they work correctly? Have you tested them? If you have tested them, I am assuming that you wrote a loop that load them up? And if you did, can you reuse that testing code here?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Teri Fisher
Ranch Hand

Joined: Jan 07, 2008
Posts: 52
I guess that's my problem, I was trying to use my addAfter in my test code to get started but was unsuccessful. Once I get going with my array I think I'll be fine, I think that I confuse myself with my variables and I'm stuck.
Teri Fisher
Ranch Hand

Joined: Jan 07, 2008
Posts: 52
I am narrowing it down to my addAfter and addBefore methods now that they are fixed (I think), my question is about the outputs. I know it is still too much code but I am not understanding my output--
1)Why is the addBefore order reversed and why does the list for test 1 not display 9 from the addAfter?
2)Why are there three sets of zeros at the end of the double list?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filling Array
 
Similar Threads
need help with java
doubts in enum and generalized code
AddAfter method
how to prevent vector to be with 10 elements as defult ?
method ... not found in class ...