Home > Java > JavaBase > The difference between class methods and instance methods in java

The difference between class methods and instance methods in java

王林
Release: 2019-11-16 15:12:09
Original
4817 people have browsed it

The difference between class methods and instance methods in java

1. Class method

Class method is a static method and needs to be modified by the static modifier in front. Variables cannot be included in class methods.

1. The object method of the class cannot be called

2. The object variable cannot be referenced

3. The class method cannot be overridden (overwritten)

4 , Class methods cannot use super, this keyword

2. Instance methods

1. You can call the object method of the class

2. You can quote Object variables

3. Instance methods can be overridden (overwritten)

4. Instance methods can use super, this keyword

Difference:

The class method is assigned a memory address when the class is loaded, so it can be called by any object after loading, and can be called directly through the class name (class name. method name), while the instance method needs to be created after The memory address will be allocated after the object.

Recommended tutorial: Java tutorial

The above is the detailed content of The difference between class methods and instance methods in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template