| <!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 <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 <strong>Browse</strong> to find the folder. If a folder is found for the current selection, that folder appears in |
| the <strong>Source Folder</strong> field as the container for the new class. |
| </li> |
| <li> |
| Select the <strong>Enclosing Type</strong> checkbox and type the name of the enclosing type in the <strong>Enclosing Type</strong> field. You can |
| also click <strong>Browse</strong> to select the enclosing type for the new class. |
| </li> |
| <li> |
| In the <strong>Name</strong> field, type a name for the new class. |
| (Optionally, in a 5.0 project, add type parameters enclosed in <strong><</strong> and <strong>></strong>). |
| </li> |
| <li> |
| Select the desired modifiers by using the <strong>Modifiers</strong> radio buttons and checkboxes. |
| </li> |
| <li> |
| In the <strong>Superclass</strong> field, type or click <strong>Browse</strong> to select a superclass for the new class. |
| (Optionally, in a 5.0 project, add type arguments enclosed in <strong><</strong> and <strong>></strong>). |
| </li> |
| <li> |
| Click the <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><</strong> and <strong>></strong>). |
| </li> |
| <li> |
| If you want to create some method stubs in the new class: |
| </li> |
| <li> |
| <ul> |
| <li> |
| Select the <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 <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 <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 <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> |
| |