Monday, February 6, 2012
Horray Arrays!
So I just read the chapter about arrays in my textbook and they are real nice. I've had a little experience using them in Matlab and I think they are some of the most useful things in programming, at least for analyzing data. I like the programs you can make with arrays easily with the proper use of the Math.random() method. I almost want to make a card game based off of the example from the book. It would be fun to play cards with something that I programmed myself. It get's boring just making "useless" programs for the homework assignments for class. I think I will enjoy, and learn more, if I set out alone and try to make a program that will aid/entertain me each week. Which reminds me, I did see another blogger (on Tumblr) who created a Java program that tracked the history of a posted photo and displayed how it was shared graphically, kind of like a family tree. I thought this was an amazing idea and I want to try to re-create it as soon as I feel I have enough programming knowledge under my belt.
For Now,
CS ADVENTURER
Wednesday, February 1, 2012
Java isn't JavaScript
Not really related to learning Java itself, but today I was wondering what JavaScript was and if it was related to Java. Indeed they are both programming languages and are both Object Oriented. Java was created by Sun Microsystems, while JavaScript (formally known as LiveScript) was created by Netscape. Supposedly JavaScript is more simple than Java as far as the language goes, but Java is probably more powerful. JavaScript is mainly used for HTML documents, while Java can be used to program outside of a web-browser.
So there you have it. Java is not the same as JavaScript!
Stack Attack Attack
So after learning how to use a method I wanted to learn how a method works. As far as I can understand, the computer allocates memory for variables and their assigned values when a method is invoked. The main method, that is the method that is first executed when a Java program starts, creates variables and assigns values to them. If you invoke another method based on values from variables in the main method, the new method creates variables and then fills them with the values from the main method. After the new method is done calculating using the values and sends off the result, all the variables and values are deleted from the stack since they don't need to be used anymore. I think this is all correct, as far as my understanding is for now, I'll see if it is true when I write some code using methods.
Since the variables and their values are separated and deleted within the stacks when they aren't being used, the variables of different methods (even if they have the same name) are completely unique and independent of each other.
Subscribe to:
Posts (Atom)