在 Eclipse 中,创建 class 时的“封闭类型”是什么?
In Eclipse, what is 'Enclosing type" when creating a class?
在 Eclipse 中,当您创建 class 时,会出现一个显示 'Enclosing type' 的复选框。有谁知道它的作用?我附上了截图。
您可以使用 Enclosing type
选项添加 nested class
例如Classcom.A,将其添加为新的ClassB
的封闭类型
它将创建一个嵌套的 class B
public class A {
private static class B {
}
}
更多内容见Eclipse Help
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");
}
}
在 Eclipse 中,当您创建 class 时,会出现一个显示 'Enclosing type' 的复选框。有谁知道它的作用?我附上了截图。
您可以使用 Enclosing type
选项添加 nested class
例如Classcom.A,将其添加为新的ClassB
的封闭类型它将创建一个嵌套的 class B
public class A {
private static class B {
}
}
更多内容见Eclipse Help
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");
}
}