search
HomeJavaJavagetting StartedJava functions - similarities and differences between constructors and member functions

Java functions - similarities and differences between constructors and member functions

Nov 30, 2019 pm 04:37 PM
javathe differencemember functionConstructor

Java functions - similarities and differences between constructors and member functions

Similarities and differences between constructors and member functions

1. External call angle

Construction Functions can only be called when the object is created;

Member functions can only be called after the object is created and can be repeated.

Related video tutorial sharing: java video

2. Return value angle

The constructor does not need to return Value;

Member functions are optional.

3. Permission modifiers

The constructor can use any permission modifier;

The member function can also use any permission modifier.

4. Internal calls

The constructor can call member functions, but this member function is generally not treated as an object behavior;

Constructor function You can call the constructor, and this (parameter list) calls other constructors in the current class;

Constructors cannot call each other, it will recur infinitely and this(...) must be in the first sentence! Prevent value overwriting;

Member functions can call member functions, member functions cannot call constructors, but they can call new. (The constructor can have the same name as the member function!)

Recommended related articles and tutorials: Zero Basic Introduction to Java

The above is the detailed content of Java functions - similarities and differences between constructors and member functions. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment