java of several different types of methods

I. There are three types of methods in java: constructors, class methods and instance method

1. Why do we have to figure out if the constructor exist? So first we have to figure out all the construction method, is not it? If you want to beat a person, first of all not to exercise their own, but to understand the opponent.
We first look at the constructor:
(1) there is no type of construction method, which means that it can not return value
(2) the name of the constructor must be identical to the name of it in the class, which indirectly indicates that it and its class is relations binding
(3) there must be a class constructor, if not declared, the compiler will automatically add an empty constructor, which further indicates that the binding relationship between it and the class
(4) only through constructor new calls
can be summed up: the class constructor is a special method, when the need to use it to create an object constructor, indirectly derived constructor is to be used when creating an object.

2. Examples of the method is a general method, which has a type, the object can be referenced by that class variable may operate

3. class with a static method is a modified instance method, also known as static methods, its role is to be a reference class methods, class variables class methods can only operate directly through the class name directly.

Above learning summary includes personal, such as the existence unreasonable, welcome to point out, learn from each other.

Published 35 original articles · won praise 0 · Views 1319

Guess you like

Origin blog.csdn.net/c1776167012/article/details/102687737