Mindmap
Java Objects
Inhalt der Mindmap
Java Objects
Fields
- Variables applying to an object
- Ex: Assigning variables like age, salary, position, address, etc. to an object within a class
- Variables applying to an object
Classes
- Blueprints to create objects of the same type and fields.
- Ex: Creating an employee class with Age and Position field allows creation of Employee objects with Age and Positions as well.
- Blueprints to create objects of the same type and fields.
Methods
- Defines actions which a class's objects can do. Consists of a declaration and a body.
- Declaration
- Consists of a return value, method name, and a list of arguments
- Body
- Contains the code which performs the action
- Ex: int add (int a, int b). This method allows us to add 2 integers. Note: when there is more than one argument, use a comma to separate them.
- Declaration
- Defines actions which a class's objects can do. Consists of a declaration and a body.
Constructors
- Used to construct objects. If not defined, the compiler automatically adds one.
- Ex: public Employee (int ageValue, double salaryValue). This is a constructor which allows creation of an employee object. having the arguments int ageValue and double salaryValue allow the object to be created without adding extra lines of code to initialize the fields.
- Used to construct objects. If not defined, the compiler automatically adds one.
Creating an Object
- Once the class is written, you may add objects to it. This is generally done with the 'new' keyword.
- Ex: new Employee(); this creates a new employee object.
- Once the class is written, you may add objects to it. This is generally done with the 'new' keyword.
Null Keyword
- Allows a reference variable to not have a value, such as when not referencing an object.
- Ex: Book book = null; In this case, the book has a null value.
- Allows a reference variable to not have a value, such as when not referencing an object.
Informationen
- Beschreibung
- Mindmap am Java Objects, erstellt von Cody Miller am 27/08/2019.
- Erstellt von
- Cody Miller
- Aufrufe
- 3
- Bewertung