We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
在Kotlin中,可见性修饰符用于控制类、接口、函数、属性和构造函数的可见性。Kotlin中的可见性修饰符有以下几种: public:默认的可见性修饰符,表示对所有地方可见。 private:表示只在同一个文件中可见。 protected:表示只在同一个类或子类中可见。 internal:表示在同一个模块中可见。模块是指编译在一起的一组Kotlin文件。
相比于Java,Kotlin的可见性修饰符有以下几个区别: Kotlin中的默认可见性是public,而Java中的默认可见性是包级可见性。 Kotlin中的private修饰符的作用范围是文件级别的,而Java中的private修饰符的作用范围是类级别的。 Kotlin中的protected修饰符只在同一个类或子类中可见,而Java中的protected修饰符在同一个包中也可见。 Kotlin中引入了internal修饰符,表示在同一个模块中可见,而Java中没有类似的修饰符。 这些可见性修饰符可以帮助开发者控制代码的可见性,提高代码的封装性和安全性。
FROM chatGPT
Sorry, something went wrong.
修饰符 Java Kotlin public 所有类可见 所有类可见(默认) private 当前类可见 当前类可见 protected当前类、子类、同个包下的类可见 当前类、子类可见 default 同个包下的类可见(默认) 无 internal 无 同一模块的类可见
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: