Home > Java > javaTutorial > What is the definition and difference between static methods and non-static methods in Java?

What is the definition and difference between static methods and non-static methods in Java?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-04-22 12:34:08
forward
1971 people have browsed it

Concept

1. The method modified by static is a static method. Static methods do not need to be called by instance objects and can be called directly using Class.method. For example, LocalDate.now() provided by JDK8 is a typical static method, which returns the current time

2. Non-static methods are common methods without static, which usually require the object to be initialized before calling. The above validate and getValue are non-static methods that are called after instantiating the User object

Instance

    public static LocalDate now() {
        return now(Clock.systemDefaultZone());
    }
Copy after login

What are the basic data types of java

Java Basic data types are divided into:

1. Integer type, used to represent the data type of integers.

2. Floating point type, a data type used to represent decimals.

3. Character type. The keyword of character type is "char".

4. Boolean type is the basic data type that represents logical values.

The above is the detailed content of What is the definition and difference between static methods and non-static 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