November 4, 2020 I will re-study Java from scratch as a review. So, first, let's review the basic terms.
Classes and methods are described as follows. (Details will be explained below)
class class name{
Method name(argument){
//Execution process
Method body
}
}
Simply put, a class is like a blueprint that summarizes the processing required to execute a program, consisting of methods and variables. In an object-oriented language like Java, the object of programming is regarded as an object (thing). So a class is a blueprint for an object, but not the object itself. Therefore, when using a class, it is necessary to create (= instantiate) an object.
To be able to use a class, you must define it. A field is a defined variable inside the class and stores the information that the class has. The object is a collection of fields and methods.
Class definition
class class name{
//Describe fields, methods, etc.
}
Simply put, a method describes the functionality of a class and consists of the method name, arguments, and the method body. As mentioned above, the object created to use the class consists of elements called attributes and methods. You can create your own methods, but many are pre-made. Multiple methods can be described in one class.
A class is a blueprint, and an object is like a part created based on that blueprint. An object is a materialized (= instantiated) class, and in order to use the object, the following description must be made.
Use objects
Class name variable name=new class name(argument);
Objects have the meaning of "things," and the idea of building a system by combining objects like parts is called object-oriented.
Inheriting the fields and methods of a specific class to define a new class is called inheritance. When inheriting, the original class is called a superclass, and the newly created class is called a subclass.
Class inheritance
class Subclass name extends Superclass name{
//Processing content, method
}
Redefining a superclass method in a subclass is called overriding. When calling the overridden method, write as follows. (Methods with modifiers such as final and static cannot be overridden)
override
super.Method name;
It is not possible to define the same method name in the same class, but the mechanism that allows multiple methods with the same name to be defined by the argument type and sorting is called overload.
Introduction to Java: Essential Knowledge of Programming! Basic Glossary I Want to Hold First [Introduction to Java] Compiling, classes, methods ... Summary of basic terms you want to hold
Recommended Posts