blob: 115f3e078ed1e08d18643f598ab7d779b1989f61 [file]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<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">
</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 New Java Class 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> check box 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.
</li>
<li>
Select the desired modifiers by using the&nbsp;<strong>Modifiers</strong> radio buttons and check boxes.
</li>
<li>
In the&nbsp;<strong>Superclass</strong> field, type or click&nbsp;<strong>Browse</strong> to select a superclass for the new class.
</li>
<li>
Click the&nbsp;<strong>Add</strong> button to add interfaces for the new class to implement.
</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> check box 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> check box 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> check box 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.gif" alt="Related concepts" border="0" height="27" width="159">
</p>
<p>
<a href="../concepts/concepts-3.htm">Java projects</a>
</p>
<p>
<img src="../images/ngrelt.gif" alt="Related tasks" border="0" height="27" width="159">
</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.gif" alt="Related reference" border="0" height="27" width="159">
</p>
<p>
<a href="../reference/ref-126.htm">New Java Class wizard</a>
</p>
<p>
<a href="../hglegal2003.htm"><img src="../images/ngibmcpy2003.gif" alt="Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved." border="0" height="14" width="324"></a>
</p>
</body>
</html>