Day 2
Conditionals, Arrays, Loops
- Objectives
- Making Decisions
- The if/else Statement
- Boolean Expressions
- Relational Operators
- What If There Are Multiple Items in the Shopping Cart?
- Introduction to Arrays
- Array Examples
- Array Indices and Length
- Declaring and Initializing an Array
- Accessing Array Elements
- Loops
- Processing a String Array
- Using break with Loops
Objects and Classes
- Object-Oriented Programming
- Characteristics of Objects
- Classes and Instances
- The Customer Properties and Behaviors
- The Components of a Class
- Modeling Properties and Behaviors
- Customer Instances
- Object Instances and Instantiation Syntax
- The Dot (.) Operator
- Objects with Another Object as a Property
- Accessing Objects by Using a Reference
- Working with Object References
- References to Different Objects
- References and Objects in Memory
- Assigning a Reference to Another Reference
- Two References, One Object
- Arrays Are Objects
- Declaring, Instantiating, and Initializing Arrays
- Storing Arrays in Memory
- Storing Arrays of Object References in Memory
- Creating a Soccer Application
Strings, Formatting Data, Data Types
- String Class
- Concatenating Strings
- String Method Calls with Primitive Return Values
- String Method Calls with Object Return Values
- Java API Documentation
- indexOf Method Example
- Use indexOf and substring Methods
- StringBuilder Class
- StringBuilder Advantages over String for Concatenation (or Appending)
- StringBuilder: Declare and Instantiate
- StringBuilder Append
- Primitive Data Types
- Some New Integral Primitive Types
- Floating Point Primitive Types
- Textual Primitive Type
- Java Language Trivia: Unicode
- Constants
- Modulus Operator
- Combining Operators to Make Assignments
- More on Increment and Decrement Operators
- Increment and Decrement Operators (++ and ––)
- Promotion
- Caution with Promotion
- Type Casting
- Caution with Type Casting
- Using Promotion and Casting
- Compiler Assumptions for Integral and Floating Point Data Types
- Automatic Promotion
- Using a long
- Using Floating Points
- Floating Point Data Types and Assignment
Creating and Using Methods
- Basic Form of a Method
- Calling a Method from a Different Class
- Caller and Worker Methods
- A Constructor Method
- Writing and Calling a Constructor
- Calling a Method in the Same Class
- Method Arguments and Parameters
- Method Parameter Examples
- Method Return Types
- Method Return Types Examples
- Method Return Animation
- Passing Arguments and Returning Values
- More Examples
- Code Without Methods
- Better Code with Methods
- Even Better Code with Methods
- Variable Scope
- Advantages of Using Methods
- Declare a setColor Method
- Static Methods and Variables
- Example: Setting the Size for a New Item
- Creating and Accessing Static Members
- When to Use Static Methods or Fields
- Some Rules About Static Fields and Methods
- Static Fields and Methods Versus Instance Fields and Methods
- Static Methods and Variables in the Java API
- Examining Static Variables in the JDK Libraries
- Using Static Variables and Methods: System.out.println
- More Static Fields and Methods in the Java API
- Converting Data Values