Have two questions, one about arrays and one about integers

Hi, im just wondering if there is a quick solution to fill an array, similar to range in python, i usually use a for loop but is there a shorter way?

Also, i know the largest possible integer is 2,147,483,647 and long allows you do go much higher, but im wondering if theres a way to find that number automatically?, so i can code it in without having to remember it and constantly look it up in library and type it in

String[] strs = {
"Hz",
"Ui",
"7€"};

Long.MAX_VALUE

Cheers, i used Integer.MAX_VALUE;
Wasnt aware of it so thanks

As for the For loop, in python theres a way to populate an array with range(4) which would create an array

[0,1,2,3]

was just wondering if a quick way was possible in java

there is stream

import java.util.stream.IntStream;
int[] range = IntStream.rangeClosed(1, 10).toArray();
println(range.length);
for(int i = 0; i < range.length; i++) {
  print(range[i] + " ");
}

Hmm, never seen that before, copied the code into processing and it doesnt work for me, not sure what went wrong

It worked in Processing 4.0b8 but NOT in Processing 3.5.4

I did not explore why…

UPDATE

This is the Processing 3.5.4 output:

:)

Ok, i did see it works with java 1.8 but not 1.7 so that could be the issue with processing 3.54 that im still using

final int[] range = IntList.fromRange(1, 10).array();
println(str(range)); // 1 2 3 4 5 6 7 8 9
exit();

Processing.GitHub.io/processing-javadocs/core/processing/data/IntList.html#fromRange-int-

Perfect, thanks very much mate