# User Define functions

**URL:** <https://community.neo4j.com/t/user-define-functions/63655>\
**Category:** Java\
**Created:** [August 7, 2023, 2:43pm UTC](https://community.neo4j.com/t/user-define-functions/63655 "2023-08-07T14:43:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edgarlvy23](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@edgarlvy23](https://community.neo4j.com/u/edgarlvy23)\
**Post date:** [August 7, 2023, 2:43pm UTC](https://community.neo4j.com/t/user-define-functions/63655/1 "2023-08-07T14:43:33Z")

</div>

I have a java function that returns a List. The argument to this functions is local defined List used for testing. When I run this function in Neo4j desktop, it uses the local variable value instead the parameter passed from Neo4j.

---

<div class="post-metadata">

**Author:** ![adam\_cowley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/adam_cowley/32/145_2.png) [@adam\_cowley](https://community.neo4j.com/u/adam_cowley)\
**Post date:** [August 7, 2023, 2:51pm UTC](https://community.neo4j.com/t/user-define-functions/63655/2 "2023-08-07T14:51:58Z")

</div>

Can you share your code, please?

---

<div class="post-metadata">

**Author:** ![edgarlvy23](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@edgarlvy23](https://community.neo4j.com/u/edgarlvy23)\
**Post date:** [August 7, 2023, 3:57pm UTC](https://community.neo4j.com/t/user-define-functions/63655/3 "2023-08-07T15:57:03Z")

</div>

Java function

```auto
static String[] localStr = {"str1", "str2"};
Static List<String> listArgs=Arrays.asList(localStr );
  @UserFunction
  public String generateUniqueStrings(
  @Name("listArgs")List<String> listArgs){
       //..Some processing and local def of List of strings to be
        
       return List of Strings.

```

Cypher code

```auto
Match(s) where s.name contains("str")
return distinct(packageName.generateUniqueStrings(["This is a string", "This is a string", "This"])

```

Neo4j returns `["str1", "str2"]`

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [August 8, 2023, 12:58pm UTC](https://community.neo4j.com/t/user-define-functions/63655/4 "2023-08-08T12:58:38Z")

</div>

What is the purpose of your two static variables? You also have a name clash with one of them and your method parameter.

Anyways, it would helpful it you provide the body of the method, so we can see what you return and how it was calculated.
