Thursday, February 12, 2015

Chapter 4

  • A class is the blueprint for an object, it determine what the object knows (instance variables) and what the object does (methods).
  • Instances in one class all have the same methods but the methods can 'behave' differently based on the values of the instance variables.
  • You can send things to methods.
  • You can use methods to return things.  (must declare a return type to get something back(returned))
  • Methods can return "void".
  • You can make things public or private.
  • Use brackets ([#]) to get a number of things ( a certain number of objects in an array, or the number of times the dog will bark).
  • Instance Variables have a defult value, local variables do not(method parameters act as local variables).
Variable           Default value
 

Integers                     0         
    Floating Points             0.0                      
     
    Booleans                 false                 
     
    References                null                   
     
  • Instance variables are declared inside a class but not within a method.
  • Local variables are declared inside a method.
  • Since local variables do not have a default value the must be initialized (given a value or defined) before you can run the program (but they can be placed/declared before being initialized).
  • To test if primitives are the same use == .
  • To test if objects are the same use .equals () .

Friday, January 23, 2015

Chapter 3

Variables are used to hold something; a number, a value, or a frase.
Variables are created by a type and a name.
Floats need and "f" or they will be read as a double.
Java wont let you put a large variable into a smaller one.

Names cannot start with a number.
They can start with letters or $ or a _.
Names cannot be any of Java's reserved words (below).

Friday, January 16, 2015

Java Chapter 2

I learned that Java is a pile of classes.
The object are where you do things.
Use superclasses to do less work in the subclasses.
Subclasses can override superrclasses.
Objects have instance variables and methods.
Classes are not objects, just the blueprints for them.

Monday, January 12, 2015

Java Chapter 1

         Other than the way you start coding, Java is very similar to python. You can use loops(while), boolean (True/False), statements ( like int x=3), and conditionals (if ( <, >, ==) /else).
         Boolean tests belong in parenthesis.
         Use "println" to print on a new line.