简体   繁体   English

在 Eclipse 中,创建类时什么是“封闭类型”?

[英]In Eclipse, what is 'Enclosing type" when creating a class?

In Eclipse, when you are creating a class, there is a checkbox saying 'Enclosing type'.在 Eclipse 中,当您创建一个类时,会有一个复选框显示“封闭类型”。 Does anyone know what it does?有谁知道它是做什么的? I have attached the screenshot.我附上了截图。

在此处输入图片说明

You can add anested class using Enclosing type option您可以使用Enclosing type选项添加嵌套类

For example Class com.A, Add it as Enclosing type of new Class B例如 com.A 类,将其添加为新 B 类的封闭类型

1

It will create a nested class B它将创建一个嵌套的类 B

public class A {

    private static class B {

    }

}

See more in Eclipse HelpEclipse 帮助中查看更多信息

Enclosing type Select this option to choose a type in which to enclose the new class.封闭类型 选择此选项可选择将新类封闭在其中的类型。

So in this case where java file is created inside  the existing java file .like

where we selected the Test1 as Enclosing type and Test2 is the new java class file.


public class Test1 {
public class Test2 {
    }
public static void main(String[] args) {
    System.out.println("simple its the part of the class Test1");
}
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 封闭实例无效时的封闭类型行为 - Enclosing type behaviour when the enclosing instance is nullified 在Java中为两个不同的对象创建一个封闭类 - Creating an enclosing class for two different objects in java 对于angelikalanger 上的泛型类中的静态成员,“这些静态成员中的每一个对于每个封闭类型都存在一次”是什么意思 - What is meant by "Each of these static members exists once per enclosing type" for static members inside of a generic class on angelikalanger 在静态工厂方法中使用覆盖方法创建实例时,如何访问封闭类中的私有字段? - How can I access private field in enclosing class when creating instance with overridden method in static factory method? 内部类类型参数由封闭类类型变量绑定 - Inner class type parameter bound by enclosing class type variable 当组合需要访问封闭类时进行建模? - Modelling when composition needs access to enclosing class? 不是封闭的阶级 - not an enclosing class 是否有一个Eclipse模板变量用于封装类型名称的简短版本 - Is there a Eclipse template variable for short version of enclosing type name 在封闭类的超类型声明中使用嵌套类型作为泛型类型参数 - Using a nested type as a generic type argument in the enclosing class' supertype declaration “嵌套类型不能隐藏封闭类型”类 - Java 处理 - "The nested type cannot hide an enclosing type" class - Java Processing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM