gpt4 book ai didi

java - Kotlin 中有关于访问修饰符的文档吗?

转载 作者:行者123 更新时间:2023-12-01 08:02:10 25 4
gpt4 key购买 nike

我正在寻找有关 Kotlin 中访问修饰符的文档。但尚未发现。

我想了解并检查 Kotlin 和 Java 中包函数的访问修饰符以及差异保护修饰符。

[编辑]我正在寻找 Jetbrians 的公开文档。

我找到了有关访问修饰符的线程。 http://devnet.jetbrains.com/thread/451236?tstart=0

最佳答案

http://kotlinlang.org/docs/reference/visibility-modifiers.html

Classes, objects, traits, constructors, functions, properties and their setters can have visibility modifiers. (Getters always have the same visibility as the property.) There are four visibility modifiers in Kotlin:

private — visible only in the declaring scope and its subscopes (inside the same module);

protected — (applicable only to class/traitmembers) like private, but also visible in subclasses;

internal —visible everywhere within the same module (if theowner of declaring scope is visible);

public — (used by default) visible everywhere (ifthe owner of declaring scope is visible).

NOTE: Functions with expression bodies and all properties declaredpublic must always specify return types explicitly. This is requiredso that one has no chance of accidentally changing a type that is apart of a public API by merely altering the implementation.

关于java - Kotlin 中有关于访问修饰符的文档吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24547657/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com