# NeuralNetwork copied in Java from 10.6

**URL:** <https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666>\
**Category:** Coding Questions\
**Created:** [July 10, 2018, 9:12pm UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666 "2018-07-10T21:12:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [July 10, 2018, 9:12pm UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666/1 "2018-07-10T21:12:59Z")

</div>

I’m using Java & Processing  
Hey I’m trying to follow 10.6: Neural Networks: Matrix Math Part 1 - The Nature of Code, but got stuck where he makes each matrix[i] its own array. I couldnt figure out if in java it be float[] matrix[i], which didnt work or matrix[i] = []. which dont work or if there another way to do as he did but in java.  
here where I got so far in my java version yes it dont work;

```auto
class Matrix{
  float rows, cols;
  Matrix(float rows, float cols){
    this.rows = rows;
    this.cols = cols;
    float[] matrix;// here I'm suppose to make a new array I think I have
    for (int i = 0; i < rows; i++){
      float [] matrix[i]; here I need to make a new array for each i, the error pops up IDK how to fix it. 
    }
  }
}

```

---

<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 10, 2018, 9:28pm UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666/2 "2018-07-10T21:28:12Z")

</div>

2D `float` array: 🤓

```auto
class Matrix {
  final float[][] matrix;

  Matrix(final int rows, final int cols) {
    matrix = new float[rows][cols];
  }
}

```

---

<div class="post-metadata">

**Author:** ![ctrembla](https://avatars.discourse-cdn.com/v4/letter/c/aeb1de/32.png) [@ctrembla](https://discourse.processing.org/u/ctrembla)\
**Post date:** [July 10, 2018, 10:18pm UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666/3 "2018-07-10T22:18:23Z")

</div>

tyvm, what final int mean?

---

<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 10, 2018, 10:55pm UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666/4 "2018-07-10T22:55:17Z")

</div>

[https://Processing.org/reference/final.html](https://Processing.org/reference/final.html)

---

<div class="post-metadata">

**Author:** ![vadsavin-a](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vadsavin-a](https://discourse.processing.org/u/vadsavin-a)\
**Post date:** [July 12, 2018, 8:20am UTC](https://discourse.processing.org/t/neuralnetwork-copied-in-java-from-10-6/1666/5 "2018-07-12T08:20:43Z")

</div>

Ive done the topic about NNs in Processing. Look for it above yours.  
However Matrix stuff works correctly, back propogation algorithm has some problems there
