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.
The operating environment of this tutorial: windows7 system, java8 version, DELL G3 computer.
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) { .....; }
Java language is a strongly typed language, and strong type includes two meanings:
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.
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:
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!