blob: 623db512b1198b495e354ba24e5d294fcfa9914a [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 top-level 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 top-level class
</h1>
<p>
You can create classes that are not enclosed in other types.
</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 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.
(Optionally, in a 5.0 project, add type parameters enclosed in <strong>&lt;</strong> and <strong>&gt;</strong>).
</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 checkboxes:<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.
(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:
<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> 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>
<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-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.png" alt="Related reference" border="0" >
</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>
</body>
</html>