0
Array in Java
I have to make a Dog list class that is in an array form, I need to have an adding method that adds a dog to my list (array) I need to have a removing method that removes a dog from my list(array) I also need to check if a dog exists in my list (array) Please help me out with the methods I have a hard time knowing How to make them work
4 Answers
+ 2
You would have a field in your DogList class to store all the dogs:
private List<Dog> dogList = new ArrayList<>();
Your method signatures might look like this:
void addDog(Dog dog) { }
void removeDog(Dog dog) { }
boolean dogExists(Dog dog) { }
+ 2
If you have an array of dogs, then you can loop through the array and check each element if it equals to the dog that you are looking for.
0
we are allowed only to use Array .
Yes I did those basics but I donât know whst to put in the methods you know how can I check if a dog exisys for example.
0
Thanks guys I git help but it was difficuly I will get back to ask aclarations