Re: Need help with Vectors
Re: Need help with Vectors
My question is what can I do to make my code work. I have ran it in the test and it has just failed. I have been at this for quite a while and since it's my first time doing Linked Lists and Vectors I am very confused.
Re: Need help with Vectors
Quote:
Originally Posted by
Locky
My question is what can I do to make my code work. I have ran it in the test and it has just failed. I have been at this for quite a while and since it's my first time doing Linked Lists and Vectors I am very confused.
Run a debugger to figure out where your code is different from what you expect. Get it narrowed down to a couple lines, then ask a specific question.
Re: Need help with Vectors
Thats the problem. I am unsure where I am going wrong as this is my first attempt at Linked List and also at Vectors.
I know this code is wrong but I would like to know if I have done anything right:
Code java:
public boolean addGroup(Vector<Object> objects, int start)
{
boolean result = false;
{
Vector<Object>a = new Vector<Object>();
a.addAll(objects);
result = true;
}
return result;
}
Re: Need help with Vectors
Your posted code is missing quite a bit of information, and posting where it fails in the test will help explain what the problem is. Based upon what you have so far, you add all the parameter objects to a Vector which has the scope of the addGroup function eg the vector is lost as soon as the function exits, which I presume is not the behavior you wish.
Re: Need help with Vectors
Did you get it sorted and submitted after Jay?
Nice tip on using a debugger copeg, figured out how to set a breakpoint and step through/over methods to see how they work. Always wanted to see a method go through each step and watch the cogs turn, will be handy in future.