# Overloading functions: is there anyway to overload functions if they take arraylists?

**URL:** <https://discourse.processing.org/t/overloading-functions-is-there-anyway-to-overload-functions-if-they-take-arraylists/22169>\
**Category:** Beginners\
**Created:** [June 26, 2020, 12:55am UTC](https://discourse.processing.org/t/overloading-functions-is-there-anyway-to-overload-functions-if-they-take-arraylists/22169 "2020-06-26T00:55:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [June 26, 2020, 12:55am UTC](https://discourse.processing.org/t/overloading-functions-is-there-anyway-to-overload-functions-if-they-take-arraylists/22169/1 "2020-06-26T00:55:26Z")

</div>

the following fails at compile time and says they’res a duplicate function,

```auto
void saveData(ArrayList<String> a){
    if(click){
      for(int i=0;i<a.size();i++)
        output.println(a.get(i));
        saveTo();
    }
  };
  
  void saveData(ArrayList<Float> a){
    if(click){
      for(int i=0;i<a.size();i++)
        output.println(a.get(i));
        saveTo();
    }
  };

```

however the following works no problem,

```auto
void saveData(String []a){
    if(click){
      for(int i=0;i<a.length;i++)
        output.println(a[i]);
        saveTo();
    }
  };
  
  void saveData(float []a){
    if(click){
      for(int i=0;i<a.length;i++)
        output.println(a[i]);
        saveTo();
    }
  };

```

I’m thinking this is probably due to the logic of the logic of processing, but am I perhaps missing something? This isn’t really and issue as I can simply process the information outside the file saving function but as it threw an error I was just intrigued.

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [June 26, 2020, 2:16am UTC](https://discourse.processing.org/t/overloading-functions-is-there-anyway-to-overload-functions-if-they-take-arraylists/22169/2 "2020-06-26T02:16:17Z")

</div>

I think it has something to do with `type erasure`. I found this article and it looks like `instanceof` is a possible solution.

[https://wiki.sei.cmu.edu/confluence/plugins/servlet/mobile?contentId=88487555#content/view/88487555](https://wiki.sei.cmu.edu/confluence/plugins/servlet/mobile?contentId=88487555#content/view/88487555)
