# \[SOLVED\] Properties in Processing

**URL:** https://discourse.processing.org/t/solved-properties-in-processing/12569
**Category:** Beginners
**Created:** [July 7, 2019, 5:35pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569 "2019-07-07T17:35:05Z")
**Posts on this page:** 5
**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: [July 7, 2019, 5:35pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569/1 "2019-07-07T17:35:05Z")

</div>

I’m converting a project from p5.js to processing and am struggling to find the equivalent in processing. I’m using the p5.js properties

```auto
var a = {};

```

so that I can later access and update this variable as such;

```auto
var b = steps

if(a[b]&&b<a[b]){
  a[b] = steps;
}

```

However I dont understand how to achieve the same effect in processing.

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 7, 2019, 5:59pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569/2 "2019-07-07T17:59:27Z")

</div>

- Processing is a Java library. And Java is a strongly typed language. ☕
- And under Processing’s current Java version 8, we have to specify the datatype of each declared variable.
- Also, Java arrays can’t change its _length_ later:  
[Processing.org/reference/Array.html](http://Processing.org/reference/Array.html)
- If we need to do so, we’re gonna need an ArrayList instead:  
[Processing.org/reference/ArrayList.html](http://Processing.org/reference/ArrayList.html)  
[Forum.Processing.org/two/discussion/8080/why-use-arraylist-instead-of-array-with-append](http://Forum.Processing.org/two/discussion/8080/why-use-arraylist-instead-of-array-with-append)
- You can check the sketches from the link below, which are available for both Java Mode & p5.js versions: 🔗

> **[r/processing - OpenProcessing: converting code written in Java to JavaScript](https://www.reddit.com/r/processing/comments/7dqqvh/openprocessing_converting_code_written_in_java_to/dq0ecac/?utm_source=share&utm_medium=web2x)**
>
> 9 votes and 14 comments so far on Reddit

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 7, 2019, 6:05pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569/3 "2019-07-07T18:05:20Z")

</div>

Another resource:

> **[processing/p5.js](https://github.com/processing/p5.js/wiki/Processing-transition)**
>
> p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Proces...

🙂

---

<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: [July 7, 2019, 7:21pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569/4 "2019-07-07T19:21:18Z")

</div>

I understand Arraylists, these allow you to create a variable size array, and allows you to use the get method to retrieve the values and the add method to add values. However what I’m looking for is a way to implement the following functionality.

```auto
function super_path(){

if(pathfind3.toggle===1){

for(var i=nodestar.length-1;i>-1;i--){
    var b = backupstar[i].original_id;
    nodestar[i].imprinted_by[b] = true;

    var next = nodestar[i].neighbourNode(true,b,backupstar[i]);
    if(next){
        //a++;
        nodestar[i].highlight();
        next[1].node_to_node_dist[b] = nodestar[i].node_to_node_dist[b] + next[0];
        backupstar[i].nodesconnected[next[1].original_id] = next[1].node_to_node_dist[b];
        if(!nodestar[i].path_ref[b]){
        nodestar[i].path_ref[b] = [nodestar[i]]
        }
        next[1].path_ref[b] = [nodestar[i].path_ref[b],next[1]];
        next[1].path_ref[b] = next[1].path_ref[b].flat();
        backupstar[i].pathtable[next[1].original_id] = [next[1].path_ref[b]];
        stackstar[i].push(nodestar[i]);
        starhist[i].push(nodestar[i]);
        trimStackStar(stackstar[i],b)
        nodestar[i] = next[1];
      }

    else if(!next&&stackstar[i].length>0){

      nodestar[i] = stackstar[i].pop();
    }
    else{
     
    }}}

};

```

Backupstar[i] is used as a reference and each visited object is marked with the id contained in backupstar[i] and its distance to it. Backupstar[i] is also marked with all the cells which it has visited, and in this way I can check the distance from the original backupstar[i].

Using an array would not allow me to solve my problem, as the property which I’m creating contains both the cell id and distance. If I were using an array i understand that I could use a multidimensional array, ie 2 deep. But then i would not be able to use the include function to check the values it contained unless i iterated with a loop, which can become quite costly.

---

<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: [July 7, 2019, 9:22pm UTC](https://discourse.processing.org/t/solved-properties-in-processing/12569/6 "2019-07-07T21:22:00Z")

</div>

Found the solution.

The HashMap type, acts almost exactly like the properties type in javascript;

`HashMap<String,Integer> ca = new HashMap<String,Integer>();`

[https://processing.org/reference/HashMap.html](https://processing.org/reference/HashMap.html)
