本文介绍了Java中的默认访问修饰符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我没有明确说明方法或实例变量的默认访问修饰符是什么?

What is the default access modifier for a method or an instance variable if I do not state it explicitly?

例如:

package flight.booking;

public class FlightLog
{
    private SpecificFlight flight;

    FlightLog(SpecificFlight flight)
    {
        this.flight = flight;
    }
}

此构造函数的访问修饰符是受保护的还是包的?可以在同一个包中的其他类( flight.booking )调用此构造函数吗?

Is the access modifier of this constructor protected or package? Can other classes in the same package, which is flight.booking, call this constructor?

推荐答案

来自Java

成员级别,您也可以使用public修饰符或 no modifier (package-private),就像使用顶级类一样,并且具有相同的含义。

At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning.

你可以在这里阅读全文():

Full story you can read here ():

这篇关于Java中的默认访问修饰符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 01:44