search
HomeJavaJavagetting StartedWhat does void mean in java

What does void mean in java

Mar 01, 2023 pm 07:19 PM
javavoid

In Java, void means "empty", that is, "returns nothing". When the method is declared, it means that the method has no return value. Void corresponds to a wrapper class "java.lang.Void". The Void class is modified with final and is a non-instantiable placeholder class used to save a reference to a Class object that represents the Java keyword void.

What does void mean in java

The operating environment of this tutorial: windows7 system, java8 version, DELL G3 computer.

1. Overview

void is a keyword in Java. In java learning, void is included in the definition of Java main method. Figure, as follows:

public static void main(String[] args) {
    .....;
}
  • Anyone who has studied Java knows that void means empty. If you ask an expert, the expert will tell you: "void is nothing, you just need to Remember that void is empty. When the method is declared, it means that the method has no return value ".
  • Compared with the C language, there are four data types in C, including empty type, which says "There is a type of function that is not needed after calling it. Returns a function value to the caller. This function can be defined as an "empty type" .

Java language is a strongly typed language, and strong type includes two meanings:

  • 1. All variables must be declared first and then used
  • 2. Variables of a specified type can only accept values ​​whose type matches the type.

From the syntax of the method declaration, we can see that the definition of the method must have a return value, and the type of the method return value needs to be determined; when the method is defined with void, it means there is no return value, so it can be seen that void should be regarded as a data type .And there are only two data types in Java, namely basic data types and reference data types.

Basic data types (8 types) : byte, short, int, long,; char; float, double; boolean.

Reference types: classes, interfaces, array types, and a special null class.

2. So what is the type of void in java?

In fact, void also has corresponding packaging classes java.lang.Void, but we cannot directly operate them . It inherits from Object, as follows:

public final class Void extends Object {
    /*
     * The Void class cannot be instantiated.
     */
    private Void() {}
}

Searching for online information, there is probably this explanation:

  • Void - Class in java.lang
  • Void class It is a non-instantiable placeholder class, used to save a reference to a Class object that represents the Java keyword void.

For more programming-related knowledge, please visit: Programming Teaching!!

The above is the detailed content of What does void mean in java. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

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.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment