# Beginners

**URL:** https://discourse.processing.org/c/processing/processing-beginners/14.md?page=31

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

**Page:** 32

---

## ["Case expressions must be constant expressions" with final int](https://discourse.processing.org/t/case-expressions-must-be-constant-expressions-with-final-int/16109)

<div class="topic-metadata">

**Author:** [@TurboSlayer](https://discourse.processing.org/u/TurboSlayer)\
**Replies:** 12\
**Last updated:** [December 6, 2019, 3:47pm UTC](https://discourse.processing.org/t/case-expressions-must-be-constant-expressions-with-final-int/16109 "2019-12-06T15:47:12Z")

</div>

I get an error saying “Case expressions must be constant expressions”. I couldn’t fix it no matter what. Is the only solution to change xSpeed as well as origxSpeed or is there a way to set origxSpeed to xSpeed without g…

---

## [Understanding code](https://discourse.processing.org/t/understanding-code/16155)

<div class="topic-metadata">

**Author:** [@Jackieh111](https://discourse.processing.org/u/Jackieh111)\
**Replies:** 2\
**Last updated:** [December 5, 2019, 5:39pm UTC](https://discourse.processing.org/t/understanding-code/16155 "2019-12-05T17:39:11Z")

</div>

float c = ((img.pixels\[(x+y\*img.width)\] \>\> 8) & 0xFF)/255.0; can you tell me what this code is doing - I know it is extracting G value of RGB and then is it diving by 255 to get hex value? Thanks!

---

## [Array Lists creating/removing objects in a class](https://discourse.processing.org/t/array-lists-creating-removing-objects-in-a-class/16139)

<div class="topic-metadata">

**Author:** [@davidclue](https://discourse.processing.org/u/davidclue)\
**Replies:** 2\
**Last updated:** [December 5, 2019, 12:24pm UTC](https://discourse.processing.org/t/array-lists-creating-removing-objects-in-a-class/16139 "2019-12-05T12:24:22Z")

</div>

Hi I am wondering how to create objects from a classes method and what a ConcurrentModificationException is and why I’m getting it. I am a student and I am confused to why I keep getting this error in my code. ArrayList\<…

---

## [Problem with dividing](https://discourse.processing.org/t/problem-with-dividing/16071)

<div class="topic-metadata">

**Author:** [@24stevek](https://discourse.processing.org/u/24stevek)\
**Replies:** 13\
**Last updated:** [December 5, 2019, 8:03am UTC](https://discourse.processing.org/t/problem-with-dividing/16071 "2019-12-05T08:03:29Z")

</div>

Hi! I am currently making a program that draws a variety of graphs, and I’ve finished with the bar graph and line graph. They work well, and I am trying to add another function: a pie graph. I am making the drawing part…

---

## [Passing this as a method](https://discourse.processing.org/t/passing-this-as-a-method/15796)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 6\
**Last updated:** [December 4, 2019, 2:32am UTC](https://discourse.processing.org/t/passing-this-as-a-method/15796 "2019-12-04T02:32:54Z")

</div>

Controlp5 passes this as a method, controlP5 = new ControlP5(this) How do you create a class that can do this?

---

## [I need tips about num input:)](https://discourse.processing.org/t/i-need-tips-about-num-input/15973)

<div class="topic-metadata">

**Author:** [@24stevek](https://discourse.processing.org/u/24stevek)\
**Replies:** 11\
**Last updated:** [November 30, 2019, 12:01pm UTC](https://discourse.processing.org/t/i-need-tips-about-num-input/15973 "2019-11-30T12:01:55Z")

</div>

HI! I need to get a number input, but it’s all mixed up. I’ve tried Keypressed - that doesn’t work well because it notices spacebar as input too and using virtual buttons like a calculator - that works well but is inc…

---

## [Multiple Type Dictionaries](https://discourse.processing.org/t/multiple-type-dictionaries/15786)

<div class="topic-metadata">

**Author:** [@KeirMeDear](https://discourse.processing.org/u/KeirMeDear)\
**Replies:** 2\
**Last updated:** [November 29, 2019, 8:28pm UTC](https://discourse.processing.org/t/multiple-type-dictionaries/15786 "2019-11-29T20:28:25Z")

</div>

In processing, is there a way to have a dictionary with multiple types (e.g. String, int, float, etc) I can’t seem to find if there is or not in the docu, the best I’ve found is single type ones like a float dict, int d…

---

## [Println(color) gives strange color number](https://discourse.processing.org/t/println-color-gives-strange-color-number/15654)

<div class="topic-metadata">

**Author:** [@Ruchi](https://discourse.processing.org/u/Ruchi)\
**Replies:** 17\
**Last updated:** [November 25, 2019, 5:03pm UTC](https://discourse.processing.org/t/println-color-gives-strange-color-number/15654 "2019-11-25T17:03:19Z")

</div>

color c=color(255,1); println(c); console 33554431 color c=color(200,129); println(c); console -2117547832 color c=color(12,127); println(c); console 2131495948 The negative & positive sign is related to alpha & …

---

## [What does this error mean?](https://discourse.processing.org/t/what-does-this-error-mean/15794)

<div class="topic-metadata">

**Author:** [@24stevek](https://discourse.processing.org/u/24stevek)\
**Replies:** 8\
**Last updated:** [November 25, 2019, 1:19pm UTC](https://discourse.processing.org/t/what-does-this-error-mean/15794 "2019-11-25T13:19:01Z")

</div>

Hello! I am making a bar graph program and I need to get some numbers in an array. But an error pops out and I don’t get what it means. Can anybody tell me what this error is and what I have to do in order to fix it? T…

---

## [How to get a number array in processing\_beginner](https://discourse.processing.org/t/how-to-get-a-number-array-in-processing-beginner/15759)

<div class="topic-metadata">

**Author:** [@24stevek](https://discourse.processing.org/u/24stevek)\
**Replies:** 7\
**Last updated:** [November 25, 2019, 7:00am UTC](https://discourse.processing.org/t/how-to-get-a-number-array-in-processing-beginner/15759 "2019-11-25T07:00:32Z")

</div>

Hi. I gave up on my electrostatic project and started a graph project. I need to receive an array to make a graph, but “ArrayIndexOutOfBoundsException: 1” keeps popping up. Can anyone tell me a way of getting a number a…

---

## [Help creating simple animation](https://discourse.processing.org/t/help-creating-simple-animation/14089)

<div class="topic-metadata">

**Author:** [@clpeng](https://discourse.processing.org/u/clpeng)\
**Replies:** 23\
**Last updated:** [November 25, 2019, 1:20am UTC](https://discourse.processing.org/t/help-creating-simple-animation/14089 "2019-11-25T01:20:20Z")

</div>

Trying to replicate a simple animation I did years ago in assembler. I want to draw a rectangle, display it for a set time, erase it, then draw another slightly larger rectangle, display for a time, erase, etc. Thanks! …

---

## [Issue with keyPressed](https://discourse.processing.org/t/issue-with-keypressed/15755)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 3\
**Last updated:** [November 25, 2019, 1:16am UTC](https://discourse.processing.org/t/issue-with-keypressed/15755 "2019-11-25T01:16:38Z")

</div>

I want to add some key functionality to my program, it works fine for arrow keys but not for other keys if(keyPressed && keyCode ==37){ flyingx += 0.1; } if(keyPressed && keyCode ==39){ …

---

## [Cascaded function call question](https://discourse.processing.org/t/cascaded-function-call-question/15688)

<div class="topic-metadata">

**Author:** [@meow](https://discourse.processing.org/u/meow)\
**Replies:** 11\
**Last updated:** [November 24, 2019, 6:40pm UTC](https://discourse.processing.org/t/cascaded-function-call-question/15688 "2019-11-24T18:40:46Z")

</div>

int chi(int a) { int b = foo(a); if(b \< 5 ) { return a - b; } else { return a - b + 10; } } 47 283 0 how to do this question?

---

## [What comes after cols and rows?](https://discourse.processing.org/t/what-comes-after-cols-and-rows/15729)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 5\
**Last updated:** [November 24, 2019, 2:42am UTC](https://discourse.processing.org/t/what-comes-after-cols-and-rows/15729 "2019-11-24T02:42:15Z")

</div>

General question. What is the standard/conventional name for a component in the z direction

---

## [Char to int producing different result](https://discourse.processing.org/t/char-to-int-producing-different-result/15655)

<div class="topic-metadata">

**Author:** [@Ruchi](https://discourse.processing.org/u/Ruchi)\
**Replies:** 5\
**Last updated:** [November 23, 2019, 9:34am UTC](https://discourse.processing.org/t/char-to-int-producing-different-result/15655 "2019-11-23T09:34:34Z")

</div>

String bin ="100"; char bit; float sum; void setup(){ size(500,200); noLoop(); sum=0; } void draw(){ background(0); for(int i=0;i\<bin.length();i++){ bit = bin.charAt(bin.length()-1-i); //println(bi…

---

## [What is boolean?](https://discourse.processing.org/t/what-is-boolean/15675)

<div class="topic-metadata">

**Author:** [@meow](https://discourse.processing.org/u/meow)\
**Replies:** 13\
**Last updated:** [November 21, 2019, 10:40pm UTC](https://discourse.processing.org/t/what-is-boolean/15675 "2019-11-21T22:40:52Z")

</div>

what is boolean and how do they work in processing

---

## [Classes and Arrays](https://discourse.processing.org/t/classes-and-arrays/15702)

<div class="topic-metadata">

**Author:** [@NewbCoder](https://discourse.processing.org/u/NewbCoder)\
**Replies:** 1\
**Last updated:** [November 21, 2019, 9:36pm UTC](https://discourse.processing.org/t/classes-and-arrays/15702 "2019-11-21T21:36:07Z")

</div>

Hello, I’m having issues with += operator to calculate the average of an array of type class. This is occurring in my Calculate\_Average function. For some reason, it does not agree with the object I’ve created. I was won…

---

## [Easily converting keycode to string](https://discourse.processing.org/t/easily-converting-keycode-to-string/15649)

<div class="topic-metadata">

**Author:** [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Replies:** 2\
**Last updated:** [November 19, 2019, 11:53pm UTC](https://discourse.processing.org/t/easily-converting-keycode-to-string/15649 "2019-11-19T23:53:59Z")

</div>

Is there a way to easily convert a keycode to a string, without having to create a case list for each letter?

---

## [How do you make a function run the same way as draw()?](https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373)

<div class="topic-metadata">

**Author:** [@24stevek](https://discourse.processing.org/u/24stevek)\
**Replies:** 13\
**Last updated:** [November 13, 2019, 12:42pm UTC](https://discourse.processing.org/t/how-do-you-make-a-function-run-the-same-way-as-draw/15373 "2019-11-13T12:42:44Z")

</div>

Hi, guys, I’m a Korean student who just started learning processing. My English might be awkward but please don’t be mad at it. So, I am making this project that shows the moving of electrons. I made an animation of an …

---

## [How to load images using an arrayList?](https://discourse.processing.org/t/how-to-load-images-using-an-arraylist/15263)

<div class="topic-metadata">

**Author:** [@B\_s](https://discourse.processing.org/u/B_s)\
**Replies:** 6\
**Last updated:** [November 8, 2019, 10:41pm UTC](https://discourse.processing.org/t/how-to-load-images-using-an-arraylist/15263 "2019-11-08T22:41:32Z")

</div>

Hello, Complete newbie to processing so any help is appreciated and apologies for my lack of language knowledge. I am trying to make a grid of 9 images that, when keyPressed, randomises the order of the images. I have …

---

## [Minor Problem with arrays and loops](https://discourse.processing.org/t/minor-problem-with-arrays-and-loops/15095)

<div class="topic-metadata">

**Author:** [@haidershah](https://discourse.processing.org/u/haidershah)\
**Replies:** 3\
**Last updated:** [November 9, 2019, 11:38pm UTC](https://discourse.processing.org/t/minor-problem-with-arrays-and-loops/15095 "2019-11-09T23:38:53Z")

</div>

PVector\[\] record = new PVector\[100\]; int curr = 0; void setup() { size(800, 800); for (int i = 0; i\<record.length; i++) { record\[i\]= new PVector(100, 100); } } void draw() { } void mousePressed() {…

---

## [Increasing the size of an object made up of two triangles](https://discourse.processing.org/t/increasing-the-size-of-an-object-made-up-of-two-triangles/14956)

<div class="topic-metadata">

**Author:** [@Anotherrat](https://discourse.processing.org/u/Anotherrat)\
**Replies:** 2\
**Last updated:** [November 9, 2019, 11:07pm UTC](https://discourse.processing.org/t/increasing-the-size-of-an-object-made-up-of-two-triangles/14956 "2019-11-09T23:07:21Z")

</div>

Hi, I am relatively new to coding and I’ve encountered a small issue. I have diamond shape made up of two triangle shapes, I’ve turned the shape in to an object that includes x & y properties, I can move it round the sc…

---

## [How to return a PVector array?](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340)

<div class="topic-metadata">

**Author:** [@Djharr](https://discourse.processing.org/u/Djharr)\
**Replies:** 2\
**Last updated:** [November 8, 2019, 7:31pm UTC](https://discourse.processing.org/t/how-to-return-a-pvector-array/15340 "2019-11-08T19:31:51Z")

</div>

HI, wondering how i’m meant to return a PVector array; public PVector VECTORS(){ PVector\[\] v = new PVector\[1000\]; for(int i =0; i\<v.length; i++){ v\[i\] = new PVector(random(width), random(height)); } return v; } t…

---

## [Unsure why I cant call a method from a class](https://discourse.processing.org/t/unsure-why-i-cant-call-a-method-from-a-class/15315)

<div class="topic-metadata">

**Author:** [@Djharr](https://discourse.processing.org/u/Djharr)\
**Replies:** 2\
**Last updated:** [November 7, 2019, 5:45pm UTC](https://discourse.processing.org/t/unsure-why-i-cant-call-a-method-from-a-class/15315 "2019-11-07T17:45:58Z")

</div>

Why does it say my DATE class or method doesnt exist? probably missing something silly but new to processing.

---

## [string.toUpperCase() behaving weirdly](https://discourse.processing.org/t/string-touppercase-behaving-weirdly/15321)

<div class="topic-metadata">

**Author:** [@TheWizardBear](https://discourse.processing.org/u/TheWizardBear)\
**Replies:** 3\
**Last updated:** [November 7, 2019, 5:19pm UTC](https://discourse.processing.org/t/string-touppercase-behaving-weirdly/15321 "2019-11-07T17:19:21Z")

</div>

I was trying to make an if statement that checks a string but isn’t case sensitive, and I came across some weird behavior: String str = "Hello World."; void setup(){ println(str.toUpperCase()); //Outputs HELLO WORLD.…

---

## [Trouble understanding for loops!](https://discourse.processing.org/t/trouble-understanding-for-loops/15211)

<div class="topic-metadata">

**Author:** [@IsaiahZ](https://discourse.processing.org/u/IsaiahZ)\
**Replies:** 5\
**Last updated:** [November 4, 2019, 3:35pm UTC](https://discourse.processing.org/t/trouble-understanding-for-loops/15211 "2019-11-04T15:35:37Z")

</div>

I am making this “illusion” and instead of coding it how I currently have it I need to use for loops and I’m not sure how to implement it for this code. I’m new so I would really appreciate the help. I would also like to…

---

## [Why use class for memory card game](https://discourse.processing.org/t/why-use-class-for-memory-card-game/15189)

<div class="topic-metadata">

**Author:** [@crazybob5](https://discourse.processing.org/u/crazybob5)\
**Replies:** 4\
**Last updated:** [November 3, 2019, 8:27pm UTC](https://discourse.processing.org/t/why-use-class-for-memory-card-game/15189 "2019-11-03T20:27:16Z")

</div>

Hi, I’m making a memory game. People are telling me to use a class for the cards, because it would be more efficient. Can someone explain me why?

---

## [Custom error throwing "Unhandled Exception Type" when called](https://discourse.processing.org/t/custom-error-throwing-unhandled-exception-type-when-called/15152)

<div class="topic-metadata">

**Author:** [@dragon\_hatcher](https://discourse.processing.org/u/dragon_hatcher)\
**Replies:** 1\
**Last updated:** [November 2, 2019, 4:20pm UTC](https://discourse.processing.org/t/custom-error-throwing-unhandled-exception-type-when-called/15152 "2019-11-02T16:20:45Z")

</div>

What am I doing wrong? Here is my code: void setup() { size(100, 100); throw new customException("test"); } class customException extends Exception{ customException(String message){ super(message); }…

---

## [On private keyword](https://discourse.processing.org/t/on-private-keyword/15139)

<div class="topic-metadata">

**Author:** [@plux](https://discourse.processing.org/u/plux)\
**Replies:** 3\
**Last updated:** [November 2, 2019, 9:24am UTC](https://discourse.processing.org/t/on-private-keyword/15139 "2019-11-02T09:24:38Z")

</div>

Hello, maybe I’m getting confused but I was expecting for this print line to return an error since I’m trying to access a private field (age) from outside its class (Parent)? Thanks class Parent{ private int age; …

---

## [Changing images with input key](https://discourse.processing.org/t/changing-images-with-input-key/14988)

<div class="topic-metadata">

**Author:** [@Kitty](https://discourse.processing.org/u/Kitty)\
**Replies:** 1\
**Last updated:** [October 28, 2019, 8:29pm UTC](https://discourse.processing.org/t/changing-images-with-input-key/14988 "2019-10-28T20:29:34Z")

</div>

I’m working with this java code and I would like to know how to change a displayed image with an input key. For example, change my currently display from im\[0\] to im\[2\]

[Previous page](https://discourse.processing.org/c/processing/processing-beginners/14.md?page=30)

[Next page](https://discourse.processing.org/c/processing/processing-beginners/14.md?page=32)
