Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 像Thread.UncaughtExceptionHandler或Map.Entry这样的接口中怎么会有点(.)?_Java_Interface - Fatal编程技术网

Java 像Thread.UncaughtExceptionHandler或Map.Entry这样的接口中怎么会有点(.)?

Java 像Thread.UncaughtExceptionHandler或Map.Entry这样的接口中怎么会有点(.)?,java,interface,Java,Interface,如果我们在oracle文档中看到像Thread.UncaughtExceptionHandler或Map.Entry这样的定义,它们被定义为公共静态接口。想知道Java是如何在内部实现或编写的吗?因为当我们尝试创建类似模式的自定义接口时,编译器会在点(.)处抛出异常 它被称为or 此代码显示了一些示例: public class A { public static void main(String[] args) { B b = new A.B(); I

如果我们在oracle文档中看到像Thread.UncaughtExceptionHandler或Map.Entry这样的定义,它们被定义为公共静态接口。想知道Java是如何在内部实现或编写的吗?因为当我们尝试创建类似模式的自定义接口时,编译器会在点(.)处抛出异常

它被称为or

此代码显示了一些示例:

public class A {

    public static void main(String[] args) {
        B b = new A.B();
        I i = new A.Impl();
        C c = new A().new C();
    }

    //nested class
    static class B { }

    //nested interface
    static interface I { }
    static class Impl implements I { }

    //inner class
    class C { }

}
它被称为or

此代码显示了一些示例:

public class A {

    public static void main(String[] args) {
        B b = new A.B();
        I i = new A.Impl();
        C c = new A().new C();
    }

    //nested class
    static class B { }

    //nested interface
    static interface I { }
    static class Impl implements I { }

    //inner class
    class C { }

}

这是因为嵌套的类型

并且可以有一个单独的类来实现线程类中定义的接口

public class ThreadGroup implements Thread.UncaughtExceptionHandler {
      //implementation to the uncaughtException method.
}

访问时,它将是
线程.UncaughtExceptionHandler(){}

这是因为嵌套的类型

并且可以有一个单独的类来实现线程类中定义的接口

public class ThreadGroup implements Thread.UncaughtExceptionHandler {
      //implementation to the uncaughtException method.
}

在访问时,它将是Thread.UncaughtExceptionHandler(){}我们可以引用这样的静态内部类。 例如:


对于引用B,我们将使用该语法。

我们可以引用这样的静态内部类。 例如:


对于引用B,我们将使用该语法。

UncaughtExceptionHandler
实际上是一个接口:)@LastMind和一个接口是一个@BinkasLaryman-您不应该要求某人查看类文件格式并建议一个接口是一个类。在java中,所有内容(包括枚举)都采用这种格式
UncaughtExceptionHandler
Thread
类中的
public
接口。尝试将
公共类
放入
公共类
中。我只是说
class
这个词可以用
type
替换。不,接口不同于class@TheLostMind类文件格式应命名为“java类型格式”,而
class
应命名为
type
,但这种设计不是我的错。Java是指带有类的类型,但我更喜欢使用单词type。虽然这是技术方面的观点,但我大体上同意接口与类或枚举不同。谢谢@BinkanSalaryman&TheLostMind。从你的对话中,我学到了更多。
UncaughtExceptionHandler
实际上是一个接口:)@lostmind和一个接口是一个@BinkanSalaryman-你不应该要求别人查看类文件格式并建议一个接口是一个类。在java中,所有内容(包括枚举)都采用这种格式
UncaughtExceptionHandler
Thread
类中的
public
接口。尝试将
公共类
放入
公共类
中。我只是说
class
这个词可以用
type
替换。不,接口不同于class@TheLostMind类文件格式应命名为“java类型格式”,而
class
应命名为
type
,但这种设计不是我的错。Java是指带有类的类型,但我更喜欢使用单词type。虽然这是技术方面的观点,但我大体上同意接口与类或枚举不同。谢谢@BinkanSalaryman&TheLostMind。从你的谈话中,我学到了更多。谢谢你的解释@CodeBenderTank需要解释@编码器
public interface A {
     public static interface B {
        void blah();
    }
 }