Johny24max
asked on
getters with collections
I am writing a getPerson( ) that takes two parameters, an integer position and a flexible-size collection that holds Person references. The method returns a Person reference found in the collection at the specified position. It also has to implement a line of code checks the validity of the position parameter. After i do this i need overload it such that the new method takes only one parameter, a flexible-size collection that holds Person references I really stuck on how to implement this?
How would the 2nd method know which element to return if its not passed the position?
ASKER
If the position parameter is not in the range 0 to last valid position in the collection, the method returns null
But aren't you saying the 2nd method will not have a position parameter.
ASKER
the second will not have a position parameter
So how will it determine what element to return?
ASKER
well i really dont know? but i just really need to figure out how to a getPerson( ) that takes two parameters, an integer position and a flexible-size collection that holds Person references. The method returns a Person reference found in the collection at the specified position. The position parameter is just a way on how you can improve the getPerson() method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i did something like this is this valid?
public String getPerson(lint p1, int p2)
{
return person;
}
public String getPerson(lint p1, int p2)
{
return person;
}
>> return person;
What's that? The 2 parameters are not being used.
What's that? The 2 parameters are not being used.