Glossary
class name
The identifier used to name a class, which serves as a blueprint for creating objects. It is also used to access static members of that class.
Example:
To change the school for all students, you'd use Student.setSchool("New School"); where **Student** is the class name.
dot operator
An operator (`.`) used in Java to access members (variables or methods) of an object or a class.
Example:
To call a static method setSchool on the Student class, you use Student.**setSchool**("New School");, utilizing the dot operator.
final (keyword)
A keyword used to declare a variable as a constant, meaning its value cannot be changed after it has been initialized.
Example:
private static **final** double PI = 3.14159; ensures that the value of PI remains constant throughout the program's execution.
instance variables
Variables that belong to a specific object (instance) of a class. Each object has its own copy of instance variables.
Example:
In a Student class, private String name; is an instance variable because each student object has a unique name.
private (access modifier)
An access modifier that restricts access to a class, method, or variable only within the class where it is declared.
Example:
**private** static final double A_BOUNDARY = 0.9; means the A_BOUNDARY can only be used or changed by code inside the Student class, ensuring its private nature.
public (access modifier)
An access modifier that makes a class, method, or variable accessible from any other class.
Example:
A **public** static String welcomeMessage; can be directly accessed and printed from outside the class using System.out.println(Student.welcomeMessage);.
static (keyword)
A keyword in Java used to declare members (variables or methods) that belong to the class rather than to any specific instance of the class.
Example:
Declaring public **static** int counter; means counter is shared by all objects of that class, demonstrating the use of the static keyword.
static methods
Methods that belong to the class itself and can be called without creating an object of the class. They can only access static variables and call other static methods.
Example:
The Math.random() method is a static method that generates a random number without needing to create a Math object.
static variables
Variables that belong to the class itself, not to any specific object instance. All objects of the class share the same copy of a static variable.
Example:
In a Game class, private static int totalPlayersOnline; tracks the total number of players across all game instances, not just for one player's game, making it a static variable.
this reference
A keyword in Java that refers to the current object. It is used to distinguish instance variables from local variables or to call other methods of the same object.
Example:
Inside a Student object's setName method, **this**.name = newName; ensures you're setting the name of the current student object.