Certainly! Here is the fully updated and unified Java review guide, now with both parts of the lesson included and organized for clarity:


๐Ÿ“˜ Java Review Guide: Classes, Methods, Strings, and Operators


๐Ÿ“ SECTION 1: Classes and Methods

โœ… Understanding Method Types

Term Description
Method A behavior or function defined in a class.
Static Belongs to the class itself. Called using ClassName.methodName().
Non-static Belongs to an individual object. Requires creating an instance to access.

๐ŸŽ‚ Example: Cake and Bakery Classes

๐Ÿ”น Static Method โ€“ listFlavorChoices

java System.out.println(Cake.listFlavorChoices());

๐Ÿ”น Non-static Method โ€“ howManyCalories

๐Ÿ”น Non-static Method โ€“ addWriting

java vanilla.addWriting("Happy Birthday");

๐Ÿ”’ Private Method โ€“ mixIngredients


๐Ÿง  Key Method Concepts

Component Description
Access Modifier public, private, etc. (controls visibility)
Return Type e.g., int, String, void
Method Name Identifier like howManyCalories
Parameters Inputs like (String message)

๐Ÿ“ SECTION 2: Strings in Java

๐Ÿ“˜ What Is a String?


๐Ÿงฑ Memory & Storage

Concept Description
Stack Stores variable references.
Heap Stores objects.
String Pool Optimized memory for string literals. Same values point to the same object.
Immutable Strings cannot be changed once created. Any changes produce a new string.

๐Ÿ“„ Declaring Strings

โœ… Common Way (String Pool used)

String a = "Hello";

โš ๏ธ Less Common (Bypassing String Pool)

String c = new String("Hello");

๐Ÿ†š Equality

Referential Equality (==)

Value Equality (.equals)

a.equals(b);          // true if values are the same
a.equalsIgnoreCase(b); // ignores capitalization

๐Ÿ›  Useful String Methods

Method Description
length() Returns the number of characters.
substring(start) Returns part of the string starting at index start.
substring(start, end) Returns characters from start (inclusive) to end (exclusive).
equals(otherString) Checks for value equality (case-sensitive).
equalsIgnoreCase(otherString) Value equality ignoring case.
compareTo(otherString) Returns difference in Unicode values; 0 if equal.

๐Ÿงช String Examples

String e = "hi";
String f = e;
String g = "howdy";
String h = new String("Hi");

// Comparisons
e == f;                  // true (same object)
e == h;                  // false (different objects)
e.equals(h);             // false (case-sensitive)
e.equalsIgnoreCase(h);  // true
g.length();              // 5
g.substring(2);          // "wdy"
g.substring(1, 4);       // "owd"

๐Ÿ“ SECTION 3: The Plus + Operator in Java

โž• Dual Purposes of +

Operation Description
Addition Adds numeric values (int + int, double + double).
Concatenation Joins two strings together.

๐Ÿ”ข Examples: Addition

3 + 5             // 8 (int)
2.0 + 4.0         // 6.0 (double)
4.2 + 3           // 7.2 (int is promoted to double)

๐Ÿ”ค Examples: Concatenation

"Hello" + " " + "World"   // "Hello World"
"Score: " + 100           // "Score: 100"

โš ๏ธ Java will implicitly convert non-strings (e.g., int, double) to strings when used in concatenation.


โœ… Summary Recap

๐ŸŽฏ Classes & Methods

๐ŸŽฏ Strings

๐ŸŽฏ Operators


Let me know if you want practice questions, diagrams, or code samples for any part of this guide!