Before I begin let me say that this is only an explanation of the concept of variables. This is not how variables actually work inside of a computer.
A variable is like a box that you give a label to, inside of which is a value. This is the same thing as in algebra when we say x + 5 = 10. One way to look at this is to say, "there is a box labeled x with the number 5 inside". In the language of processing, that would look like this:
Algebra is powerful. However, in algebra you can only label the boxes with a letter of the alphabet and the only thing you can put in the box is a number. In computer programming the nice thing is that you can name the boxes (almost) anything you want, and you can put all sorts of things inside the box.
You could have a box called "name" inside of which is the name "Bob"
Even better, you can have a box called "names" and store a list of multiple names inside of it.
You can have a true or false box called isHappy, and store whether or not someone is happy.
You could even make boxes of your own. For example, an apple box called "apples" that stores a list of different apple objects inside (apples you programmed of course).
These are just a few of the different types of "boxes" in Processing. You'll notice that in both of the previous examples I have used the word int, String, or boolean before I said what the box was called. This is because Processing won't allow us to put just any old thing in any old box. The Processing language is what is known as a "strongly typed" language. Each type of variable gets to have it's own box custom designed to fit the size of the box's content. This allows Processing to fun faster and more efficiently because it allocated the right amount of space in the warehouse (memory) and will know what to expect when retrieving the box. Not all languages are like this, some are "loosely typed". You put what ever you want in the box and they'll figure it out after they open the box up.
As I said, there are many different types of boxes in Processing. When you're just starting out you'll want to know about the following types of boxes.
1) int - A box which contains an integer, a number without a decimal point; 3, 7, 13, 28.
2) float - A box which contains a floating point number, a number with a decimal; 1.0, 4.3, 2.80, 7.28401384000
3) char - A box with a single character inside; 'a', 'b', 'c', 'd'
4) String - A box with a series of characters; "Tomato", "Lettuce", "Onion"
5) boolean - a true or false box
5) Array - A list of data; {25, 35, 28, 32}. Note, you not only have to say it's an array box, but you also have to say what type of array it is. An array of integers? Strings?
void draw() {
background(245);
smooth();
//Shape mode
ellipseMode(CENTER);
rectMode(CENTER);
//His factory
stroke(0);
fill(180,172,25);
rect(mouseX,mouseY,50,70);
//His mental
stroke(0);
fill(0,182,17);
ellipse(mouseX,mouseY-85,100,130);
//Por que mira
fill(mouseX,0,mouseY);
ellipse(mouseX-19,mouseY-90,30,50);
ellipse(mouseX+19,mouseY-90,30,50);
//Por que nos move
line(mouseX-20,mouseY+35,pmouseX-20,pmouseY+90);
line(mouseX+20,mouseY+35,pmouseX+20,pmouseY+90);
}
String[] name = {"Bob","Sue","David"};