Home > Java > Javagetting Started > body text

What does public void mean?

藏色散人
Release: 2020-01-04 10:55:24
Original
14645 people have browsed it

What does public void mean?

What does public void mean?

In Java, public is the access modifier of a class, and void represents an empty type, with no data returned.

Public void is used for rest methods, indicating that the method can be accessed in the project and has no return value.

Public is the access modifier of the class. It marks the class you define and can be accessed in that package. Public (public) can be accessed in the entire project. Private (private) can only be used in this class. protected (protected) can be accessed by subclasses and classes in the same package. There is also a default access modifier, which can only be accessed under the same package.

Extended information:

Java is an object-oriented programming language that not only absorbs the various advantages of the C language, but also abandons the incomprehensible multiple inheritance in C , pointers and other concepts, so the Java language has two characteristics: powerful and simple to use.

The meaning of public: in JAVA is that the members under public: are public members of the class. Other classes or main functions can declare an object for direct access, while the members under private: are private members, which can only be accessed by the class. The inside of the class can be accessed, but the outside of the class cannot.

class A{public:int a;private:int b;};main(){Aaa;
aa.a=1;
Copy after login

Related recommendations: "java learning"

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

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template