In Chapter 3, I learned that variables are either reference variables, or primitive variables. When declaring a variable, you need to have a type and name for that variable.
A reference variable value is the bits representing a way to get to an object on the heap. A reference variable is like a remote control. Using the dot operator (.) on a reference variable is like pressing a button on the remote control to access a method or instance variable.
A primitive variable value is the bits representing the value (5, ‘a’, true, 3.1416, etc.). Primitive variables are variables that hold fundamental values, like an integer, boolean, or float. They also come in sizes; these sizes include btye, short, int, and long.
Wednesday, January 28, 2015
Tuesday, January 20, 2015
Java Chapter 2: A Trip to Objectville
In Chapter 2 I learned about Object-Oriented Developement in Java. OO lets you add onto code that already works, and keeps it nice and organized. Some of the things I learned are that ojects "talk" to each other by calling methods in each other. When java runs, it's nothing more than object 'talking' to each other. All java code is defined as a class. Instance variables are things the object knows about itself. They represent the state of the object, and a class is like a blueprint.
Tuesday, January 13, 2015
Head First Chapter 1 Java
In chapter 1, I learned that java as many similarities to Python, but there are also a lot of differences. For example, both require a semicolon at the end of a sentence, and code blocks are defined by a pair of curly braces { }. For some differencesm if you were to set x equal to a string such as, "Hello!", in Python it would let you do that, but Java requires you to say what kind of variable it is, string x = "Hello!".
I also completed the beer song and found the error. The error is that towards the end of the song, it would print 1 bottles of beer on the wall. You can fix this by moving the if (beersleft==1) and where you set "bottles" equal to word down under the beersleft = beersleft - 1 command.
I also completed the beer song and found the error. The error is that towards the end of the song, it would print 1 bottles of beer on the wall. You can fix this by moving the if (beersleft==1) and where you set "bottles" equal to word down under the beersleft = beersleft - 1 command.
Subscribe to:
Comments (Atom)