小编Vin*_*nay的帖子

为什么这个关键字用在java接口中,它指的是什么?

我只是想我可以thisinterface.

那么,如果this关键字class在 a 中代表当前对象引用class,那么它在 a中代表什么interface

interface InterfaceOne {

    default void display() {
        this.defaultMethod();
        System.out.println("InterfaceOne method displayed");
    }

    default void defaultMethod() {
        System.out.println("defaultMethod of InterfaceOne called");
    }

}
Run Code Online (Sandbox Code Playgroud)

java interface this keyword java-8

3
推荐指数
1
解决办法
2408
查看次数

标签 统计

interface ×1

java ×1

java-8 ×1

keyword ×1

this ×1