Mindmap
Objects & Classes
Inhalt der Mindmap
Objects & Classes
Objects/Instance (Car)
- Attributes/Fields
- Color, Number of Tires, Plate Number
- Actions/Methods
- Run, Brake
- Constructing Object/Instantiating Class- use new!
- assign created object to object/reference variable
- Type/Constructor objectReference = new Constructor();
- if the reference variable does not have a value, assign null
- test if reference variable is null using == ex. if (book==null) { book=new Book(); } System.out.println(book.title);
- call an object/field using .
- objectReference.methodName objectReference.fieldName
- assign created object to object/reference variable
- Attributes/Fields
Classes are blueprints to create objects
Classes
- class className{ [class body] }
- Class Name
- Capitalize the initial of each word (Pascal), same as constructor name!
- Saving file: ClassName.java
- Capitalize the initial of each word (Pascal), same as constructor name!
- Fields (Variables)
- Capitalize initial of each word except the first (Camel) (Same for Methods)
- Primitive or references to objects (other classes)
- Methods
- Declaration/Signature
- return value, method name, list of arguments
- syntax: returnType methodName (listOfArguments)
- return type can be primative, an object, or void (return nothing)
- return value, method name, list of arguments
- Body
- code to perform action
- Main- method providing entry point to application (how to invoke a specific class)
- signature: public static void main(String[] args)
- Passing Arguments
- java className arg1 arg2 arg3
- arguments must be strings
- java className arg1 arg2 arg3
- Declaration/Signature
- Constructors
- constructorName(listOfArguments){ [constructor body] }
- used to construct an object, sometimes called a constructor method, no return value
- constructor arguments are used to initialize fields in the object
Informationen
- Beschreibung
- Computer Science Mindmap am Objects & Classes, erstellt von Marissa Farmer am 20/05/2021.
- Erstellt von
- Marissa Farmer
- Aufrufe
- 0
- Bewertung