We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys.
I have a question about images[i] = loadImage("animal" + i + ".jpg"). I have a book Learning Processing A Beginner’s Guide to Programming Images, Animation, and Interaction. I studied at page 301 and when I saw the command images[i] = loadImage("animal" + i + ".jpg"), I didn't know what is parameter in parenthesis. I know that in parenthesis takes "image name file with format". His website I downloaded examples and I saw folder Data that it has got in 10 images with call animal0.jpg, animal1.jpg etc.
How can I know what does parameter takes loadImage or someone other? Also, how can I learn very good Java? Can you help please?
Answers
"animal" + i + ".jpg"
using + like this is just concatenating the word "animal", the current value of i and the ".jpg" suffix and making a single string of them. so something like "animal0.jpg", which matches the filenames in the data folder. the result is a single string that's being used by loadImage().
how can I learn very good Java?
My best suggestion is to go to your local library and borrow a java book. Focusing in a single book is better than try to learn from different websites or different examples. On the other hand, there are really good online resources. When you find one, stick to one and go through all their learning plans. Stick to beginners guide at first.
You are focusing in java right now. You are going to find out that most concepts you learn in one programming language can also be found in other programming languages. Learning the basics is very important nevertheless.
You can always come to this forum to ask for questions or clarifications :-B
Related to your question, the operation within parenthesis is called concatenation. In java, concatenation of strings is as easy as "adding up" the different string objects. In C/C++ in contrast, it is done in a different way that feels less natural...
Kf
@iLegendX -- In addition to a good introductory book, a good companion / supplement is online tutorial sequences -- sometimes with interactive lessons.
... etc.
If you already got the basics at programming, but wish to transition to Java now, Oracle site already got tutorials for it: ~O)
http://docs.Oracle.com/javase/tutorial/java/index.html
For a more OOP game oriented transition, you should check out Greenfoot IDE:
http://www.Greenfoot.org/overview
There are some nice YouTube videos for it: O:-)
http://www.Greenfoot.org/doc/joy-of-code
You can learn basics of Java just by reading up the tutorials on the processing website.
It's beyond the basics that is difficult to learn.