blob: 57b4ec154898f43bf33fbf5e94b42a05eeceefae [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta name="GENERATOR" content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]">
<title>
Creating a nested class
</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script>
</head>
<body>
<h1>
Creating a nested class
</h1>
<p>
You can create classes that are enclosed in other types (that is, nested classes).
</p>
<ol>
<li>
Open the
<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.newWizard(newWizardId=org.eclipse.jdt.ui.wizards.NewClassCreationWizard)")'>
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png">
<strong>New Java Class</strong></a> wizard.
</li>
<li>
Edit the&nbsp;<strong>Source Folder</strong> field to indicate in which folder you want the new class to reside. You can either type a path or
click&nbsp;<strong>Browse</strong> to find the folder. If a folder is found for the current selection, that folder appears in
the&nbsp;<strong>Source Folder</strong> field as the container for the new class.
</li>
<li>
Select the&nbsp;<strong>Enclosing Type</strong> checkbox and type the name of the enclosing type in the <strong>Enclosing Type</strong> field. You can
also click&nbsp;<strong>Browse</strong> to select the enclosing type for the new class.
</li>
<li>
In the&nbsp;<strong>Name</strong> field, type a name for the new class.
(Optionally, in a 5.0 project, add type parameters enclosed in <strong>&lt;</strong> and <strong>&gt;</strong>).
</li>
<li>
Select the desired modifiers by using the&nbsp;<strong>Modifiers</strong> radio buttons and checkboxes.
</li>
<li>
In the&nbsp;<strong>Superclass</strong> field, type or click&nbsp;<strong>Browse</strong> to select a superclass for the new class.
(Optionally, in a 5.0 project, add type arguments enclosed in <strong>&lt;</strong> and <strong>&gt;</strong>).
</li>
<li>
Click the&nbsp;<strong>Add</strong> button to add interfaces for the new class to implement.
(Optionally, in a 5.0 project, add type arguments enclosed in <strong>&lt;</strong> and <strong>&gt;</strong>).
</li>
<li>
If you want to create some method stubs in the new class:
</li>
<li>
<ul>
<li>
Select the&nbsp;<strong>public static void main(String[] args)</strong> checkbox if you want the wizard to add the main method to the new class, thus
making it a starting point of an application.
</li>
<li>
Select the&nbsp;<strong>Constructors from superclass</strong> checkbox if you want the wizard to create, in the new class, a set of constructors, one
for each of the constructors declared in the superclass. Each of them will have the same number of parameters (of the same types) as the respective constructor from
the superclass.
</li>
<li>
Select the&nbsp;<strong>Inherited abstract methods</strong> checkbox if you want the wizard to generate method stubs for each of the abstract methods
that the new class will inherit from its superclass and implemented interfaces.
</li>
</ul>
</li>
<li>
Click&nbsp;<strong>Finish</strong> when you are done.
</li>
</ol>
<p>
<strong>Note:</strong> The new class is created in the same compilation unit as its enclosing type.
</p>
<p>
<img src="../images/ngrelc.png" alt="Related concepts" border="0" >
</p>
<p>
<a href="../concepts/concepts-3.htm">Java projects</a>
</p>
<p>
<img src="../images/ngrelt.png" alt="Related tasks" border="0" >
</p>
<p>
<a href="tasks-17.htm">Creating a new Java class</a><br>
<a href="tasks-18.htm">Creating a top-level class</a><br>
<a href="tasks-20.htm">Creating a class in an existing compilation unit</a>
</p>
<p>
<img src="../images/ngrelr.png" alt="Related reference" border="0" >
</p>
<p>
<a href="../reference/ref-126.htm">New Java Class wizard</a>
</p>
</body>
</html>