.Tutorial # 3. |
Slide 1 // Instantiating An Object With Different Constructors Car DefaultCar = new Car(); Car YourCar = new Car(... ..., ... ..., ... ..., ... ..., ... ...); // Return Values public boolean TurnOver(boolean blah) { return !blah; } // System.out.println() vs.System.out.print() System.out.print("He"); System.out.println("llo"); // Magic Numbers private final int WHEELS = 4; // Difference between assignment and declaration /* Summary: Declaration introduces the variable & class while Assignment assigns a variable. Assignment: The association of a value with a variable; the new value replaces any previous value associated with the variable. Assignment Statement: A statement that results in an assignment; the statement consists of the name of the variable being assigned, the assignment operator =, and an expression that gives the value that is assigned to the variable. Declaration: A java statement that introduces a variable into a Java program. A declaration of a reference variable specifies the name of the variable and the class of object to which it may refer.*/ int num = 5; // both // OR // int num; // declaration num = 5; // assignment String name = new String("John"); // both // OR // String name; // declaration name = new String("John"); // assignment name = "John"; // assignment again, same thing Snippet.java - A snippet of code we will be reviewing CarProgram.java - CarProgram (Version 2) Car.java - Car (Version 2) |