0

I have this method

public void addAttraction(Attraction c) {

}

which needs to add a element (an attraction in this case, c) to an array named Attraction[]. I tried using an ArrayList, and manually entering it using index. But niether seem to work.

This is what I tried:

public void addAttraction(Attraction c) {
    c = new Attraction();
}

It needs to give a value of 2 (when the method is used), but I get a 0.

Variable_X
  • 43
  • 6
  • 1
    Does this answer your question? [How to add new elements to an array?](https://stackoverflow.com/questions/2843366/how-to-add-new-elements-to-an-array) – domsson Jan 18 '20 at 19:10
  • That is a little bit unspecific. We need to see more to help you. – Turing85 Jan 18 '20 at 19:10
  • Here is a useful link to add an element to array: https://www.geeksforgeeks.org/how-to-add-an-element-to-an-array-in-java/ – N_Craft Jan 18 '20 at 19:12

0 Answers0