Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'. Does anyone know what it does? I have attached the screenshot.

enter image description here

like image 251
Jin Lee Avatar asked Mar 05 '19 08:03

Jin Lee


People also ask

What is enclosing type in Eclipse?

You can add a nested class using Enclosing type option. For example Class com.A, Add it as Enclosing type of new Class B. It will create a nested class B public class A { private static class B { } } See more in Eclipse Help. Enclosing type Select this option to choose a type in which to enclose the new class.

What is enclosing class in Java?

A nested class is a member of its enclosing class. Non-static nested classes (inner classes) have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class.

How do I create a new class in Eclipse?

By clicking on the File menu and selecting New → Class. By right clicking in the package explorer and selecting New → Class.


1 Answers

You can add a nested class using Enclosing type option

For example Class com.A, Add it as Enclosing type of new Class B

1

It will create a nested class B

public class A {

    private static class B {

    }

}

See more in Eclipse Help

Enclosing type Select this option to choose a type in which to enclose the new class.

like image 176
user7294900 Avatar answered Sep 30 '22 12:09

user7294900