Anyone who learns Java knows that void means null and is a keyword in java. Initially, when I knew void, it was public static void main (String[]args) {}, I remember when I was in contact with void, I always had no idea what it was, so I asked the teacher, but
The teacher just said void is not a what, you just remember void is empty, when the method declaration indicates that the method does not return the value of the line.
(no return value.) But you can use return in the method, to exit the method)
One day when learning the C data type, found that there are four types of data in C, there is actually empty type, it has such a saying "there is a class of functions, after the call does not need to return the function value to the caller, this function can be defined as" null type. Its type specifier is void, and my first reaction was, "since void in C is an empty type, what is void in Java?" ”
We all know that there are only two data types in Java, that is, the basic data type and the reference data type, what is void in Java, according to the syntax of the method declaration can be seen that the definition of the method must have a return value, you need to write out the type of the method return value, when the method definition with void decoration, Indicates that there is no return value, then the void should be considered a data type, it seems that Java does not define a data type of void, with such a problem, the search for information, there is such an explanation:
Classes in the Void-java.lang
The Void class is a non-instantiated placeholder class that maintains a reference to a class object that represents the Java keyword void.
VOID-Static variables in class Javax.management.openmbean.SimpleType
The SimpleType instance describes a value whose Java class name is java.lang.Void.
I hope that we will understand the void of some help.
What is void in Java? What's the effect?