public class和just class有什么区别? [英] what is the difference between `public class` and just `class`?

查看:98
本文介绍了public class和just class有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,如果在上课之前不写 public ,其作用与 public类相同。 。我不明白为什么会这样?当我不将类声明为 public private 时,应该显示错误受保护的。但这很好。是什么原因?

I have noticed that if don't write public before a class its works same as like a public class. I can't understand why so? It should show a error when I don't declare a class as public, private or protected. But it works fine. What is the reason?

推荐答案

公共受保护的 private 是访问修饰符。 Public表示可以由任何类,由子类保护,由类本身私有的任何类访问主题,没有修饰符表示受包保护,因此可以从同一包中的类访问该主题。

public, protected and private are access modifiers. Public means that the subject may be accessed by any class, protected by subclass, private by the class itself, no modifier means "package protected", so the subject may be accessed by classes from the same package.

主题是类,方法,成员变量。

Subject is class, method, member variable.

这篇关于public class和just class有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆