Mapa mental
Java Class
Contenido del mapa
Java Class
The class name
- A class definition must be saved in a file that has the same name as the class name
- General Syntax: class className{ [classbody] }
- Class names capitalize the initial of each word.
The fields
- Fields are variables. They can be primitives or references to to objects.
- Field names also follow the camel naming convention
- Ex. Address address;
The methods
- Methods define actions that a class's objects (or instances) can do
- Methods have a declaration part and a body
- The declaration consists of a return value, the method name, and a list of arguments. It is also called the signature of the method.
- The body contains code that performs the action
- Syntax: returnType methodName (listOfArguments)
- The method "main"
- The method main is a special method that provides the entry point to an application
- Only one class can have a main method. This method allows the class containing it to be invoked.
- Signature of main method: public static main void(String[] args)
Java Classes are a blueprint or a template to create objects of an identical type.
Constructors
- Every class must have at least one constructor. Otherwise, no objects would be created out of the class.
- Constructors are used to construct an object. If your don't define a constructor, then the compiler adds one for you.
- A constructor looks like a method and is sometimes called a constructor method. However, it doesn't have a return value.
- Must have the same name as the class.
- Syntax: constructorName (listOfArgurments) { [constructor body] }
- A constructor may have a zero argument, in which it is called a no-argument constructor
- Constructor arguments can be used to initialize the fields in the object
Objects
- Objects have attributes and can perform actions.
Información
- Descripción
- Mapa Mental sobre Java Class, creado por Saketh Maganti el 29/08/2019.
- Creado por
- Saketh Maganti · ago 2019
- Actualizado
- 29 ago 2019
- Visitas
- 0
- Valoración