blob: 502abda4970811ed91ea762a648c30e7e96bf307 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//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">
<title>
Inferring type parameters for generic type references
</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
</head>
<body>
<h1> Inferring type parameters for generic type references </h1>
Eclipse can attempt to infer type parameters for all generic type references in a
class, package, or project. This is especially useful when migrating from Java 1.4 code
to Java 5.0 code, allowing you to automatically make use of the generic classes in
Java's collections API.
<ul>
<li> Open a class in the Java editor, or in a Java view, select a class, package, or project. </li>
<li> Do one of the following:
<ul>
<li> From the menu bar, select <strong>Refactor &gt; Infer Generic Type Arguments</strong> or </li>
<li> From the pop-up menu, select <strong>Refactor &gt; Infer Generic Type Arguments</strong> </li>
</ul>
</li>
</ul>
<p>
You will be given a dialog with two configurable options:
<ul>
<li><strong>Assume clone() returns an instance of the receiver type</strong>
Well-behaved classes generally respect this rule, but if you know that your
code violates it, uncheck the box.</li>
<li><strong>Leave unconstrained type arguments raw (rather than inferring &lt;?&gt;).</strong>
If there are no constraints on the elements of e.g. <code>ArrayList a</code>, unchecking this
box will cause Eclipse to still provide a wildcard parameter, replacing the reference with
<code>ArrayList&lt;?&gt; a</code>.</li>
</ul>
Press <strong>OK</strong> or <strong>Preview</strong> to continue with the operation.
</p>
<p><strong>Note</strong>: It may in some cases be impossible to assign
consistent type parameters in a selection, or require deeper analysis
than Eclipse can perform.
</p>
<img src="../images/ngrelr.png" alt="Related reference" border="0" > <br>
<a href="../reference/ref-menu-refactor.htm">Refactoring actions</a> <br>
<a href="../reference/ref-117.htm">Refactoring dialogs</a> <br>
<a href="../reference/ref-13.htm">Java preferences</a>
</body>
</html>