Help with comparing values in an array

So, I’ve been writing various homemade neural networks, and I’ve realized that I waste a ton of time re-writing code and spending too much time writing ten billion copies of the same variable with just a different name. So I started writing a program to do it for me. Basically, I give it a txt document with the parameters listed and input vars specified, and then it generates a txt document with all the generic code. This will allow me to easily change different things about how the network functions, and allows me to tweak things like the number of layers or neurons per layer without all the hassle. I’m assuming most libraries for neural nets allow you to do this.

Point is, I ran into a problem involving making decisions based off of information in the parameters txt doc. I have the contents of the document stored in a string:

String lines[] = loadStrings(“parameters.txt”);

and I can access and edit it, (I’ve done this in processing for a separate project), but I cannot compare values in the array to integers. Basically, I want to check the number listed in the txt document and make the appropriate number of layers/neurons based off of that number. Processing, however, doesn’t let me set an integer equal to the value in the string, so I had to make the variables storing the amount of layers/neurons be strings as well.

neurons[0] = lines[searchValue + 1];
layers[0] = lines[searchValue + 2];

But now the loop I made that keeps creating layers until it has made the same amount as the value of “layers” doesn’t function.

for (int k = 1; k <= layers; k++) {
currentLayer = k;
createNeurons ();

Processing says that "the operator ‘<=’ is undefined for the argument type(s) int, String[]

Here’s a screenshot of my code. I would love it if somebody could tell me what I’m not understanding/did wrong. I’m pretty new to processing, so I’m probably missing something pretty obvious.

note: Processing also made me put the brackets at lines 12 and 32 for some reason. I don’t know why.

You can convert can get an integer from a string with Integer.parseInt()

Example sketch:

void setup() {
  String strNumber = "5";
  int value = Integer.parseInt(strNumber);

If the string has stuff besides an integer in it it will cause a bug you can solve this by using Regular Expressions to isolate the numbers. Here’s an example of that:

import java.util.regex.Pattern;
import java.util.regex.Matcher;

void setup() {
  String strNumbers = "143 is a great number but 251 is amazing!";
  Pattern pattern = Pattern.compile("(\\d+)"); // one or more digits
  Matcher matcher = pattern.matcher(strNumbers);
  while (matcher.find()) {
    int value = Integer.parseInt(;

The <= comparison can only compare two numbers looks like layers is an array of strings that’s why you’re getting that error.

My suggestion is start small make sure you can read in the lines of the file. Then you can work on parsing the numbers. And then using them. It’s easier to debug a program when you’re just adding one thing at a time.