# Have two questions, one about arrays and one about integers

**URL:** <https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500>\
**Category:** Beginners\
**Created:** [June 12, 2022, 11:20am UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500 "2022-06-12T11:20:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 12, 2022, 11:20am UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/1 "2022-06-12T11:20:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 12, 2022, 11:55am UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/2 "2022-06-12T11:55:19Z")

</div>

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

```

Long.MAX\_VALUE

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 12, 2022, 12:07pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/3 "2022-06-12T12:07:30Z")

</div>

Cheers, i used Integer.MAX\_VALUE;  
Wasnt aware of it so thanks

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 12, 2022, 12:12pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/4 "2022-06-12T12:12:23Z")

</div>

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

```auto
[0,1,2,3]

```

was just wondering if a quick way was possible in java

---

<div class="post-metadata">

**Author:** ![hotfooted](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hotfooted/32/3670_2.png) [@hotfooted](https://discourse.processing.org/u/hotfooted)\
**Post date:** [June 12, 2022, 12:18pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/5 "2022-06-12T12:18:50Z")

</div>

there is stream

```auto
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] + " ");
}

```

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 12, 2022, 12:31pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/6 "2022-06-12T12:31:02Z")

</div>

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

---

<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:** [June 12, 2022, 12:40pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/7 "2022-06-12T12:40:11Z")

</div>

> [@Mikey83](#):
>
> copied the code into processing and it doesnt work for me

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:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/c/7c8aed5532236faccb45064aa3df57989760772c.png)

`:)`

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 12, 2022, 12:42pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/8 "2022-06-12T12:42:48Z")

</div>

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

---

<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:** [June 12, 2022, 5:56pm UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/9 "2022-06-12T17:56:01Z")

</div>

> [@Mikey83](#):
>
> … I’m just wondering if there is a quick solution to fill an array, similar to range in Python,

```auto
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-](http://Processing.GitHub.io/processing-javadocs/core/processing/data/IntList.html#fromRange-int-)

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [June 13, 2022, 12:40am UTC](https://discourse.processing.org/t/have-two-questions-one-about-arrays-and-one-about-integers/37500/10 "2022-06-13T00:40:10Z")

</div>

Perfect, thanks very much mate
