# 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:** 1\
**Showing post:** 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.

---

_[View the full topic](https://discourse.processing.org/t/overloading-functions-is-there-anyway-to-overload-functions-if-they-take-arraylists/22169)._
