blob: 32a5ebdf6c19670e76dcbfcdb8cb03c9418079d5 [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 top-level class
</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
</head>
<body>
<h1>
Creating a top-level class
</h1>
<p>
You can create classes that are not enclosed in other types.
</p>
<ol>
<li>
Open the New Class wizard.
</li>
<li>
Edit the&nbsp;<strong>Source Folder</strong> field as needed to indicate in which folder you want the new class to reside. You can either type a path or
click the&nbsp;<strong>Browse</strong> button 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>
In the&nbsp;<strong>Package</strong> field, type or click&nbsp;<strong>Browse</strong> to select the package where you want the new class
to reside. Leave this field empty to indicate that you want the new class to be created in the default package.
</li>
<li>
Leave the&nbsp;<strong>Enclosing type</strong> box deselected.
</li>
<li>
In the&nbsp;<strong>Name</strong> field, type a name for the new class.
</li>
<li>
Select the <strong>public</strong> or <strong>default</strong> access modifier using the&nbsp;<strong>Modifiers</strong> radio buttons.<br>
<strong>Note:</strong> The private and protected options are available only when creating a class enclosed in a type.
</li>
<li>
Optionally, select the <strong>abstract</strong> or <strong>final</strong> modifier for the new class using the appropriate check boxes:<br>
<strong>Note:</strong> The static option is available only when creating a class enclosed in a type.
</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:
<ul>
<li>
Select the&nbsp;<strong>public static void main(String[] args)</strong> 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>
<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-19.htm">Creating a nested class</a><br>
<a href="tasks-20.htm">Creating a class in an existing compilation unit</a><a href="tasks-20.htm"></a>
</p>
<p>
<img src="../images/ngrelr.gif" alt="Related reference" border="0" height="27" width="159">
</p>
<p>
<a href="../reference/ref-121.htm">New Java Project wizard</a><br>
<a href="../reference/ref-128.htm">New Source Folder wizard</a><br>
<a href="../reference/ref-125.htm">New Java Package wizard</a><br>
<a href="../reference/ref-126.htm">New Java Class wizard</a><br>
<a href="../reference/ref-3.htm">Java Toolbar actions</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>