Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions javaguide.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ <h3 id="s3.1-copyright-statement">3.1 License or copyright information, if prese
<a id="s3.2-package-statement"></a>
<h3 id="s3.2-package-declaration">3.2 Package declaration</h3>

<p>The package declaration is <strong>not line-wrapped</strong>. The column limit (Section 4.4,
<p>Every source file must have a package declaration. <a href="https://openjdk.org/jeps/512">
Compact source files</a> are not used. (This rule obviously does not apply to
<code>module-info.java</code> files, which have a different syntax that does not include a
package declaration.)

</p><p>The package declaration is <strong>not line-wrapped</strong>. The column limit (Section 4.4,
<a href="#s4.4-column-limit">Column limit: 100</a>) does not apply to package declarations.</p>

<a id="imports"></a>
Expand All @@ -194,6 +199,16 @@ <h4 id="s3.3.1-wildcard-imports">3.3.1 No wildcard imports</h4>
<p><strong>Wildcard ("on-demand") imports</strong>, static or otherwise, <strong>are not
used</strong>.</p>

<h4 id="s3.3.1.1-module-imports">3.3.1.1 No module imports</h4>

<p><a href="https://docs.oracle.com/en/java/javase/25/language/module-import-declarations.html">
Module imports</a> <strong>are not used</strong>.</p>

<p>Example:</p>

<pre class="prettyprint lang-java">import module java.base;
</pre>

<h4 id="s3.3.2-import-line-wrapping">3.3.2 No line-wrapping</h4>

<p>Imports are <strong>not line-wrapped</strong>. The column limit (Section 4.4,
Expand Down Expand Up @@ -1111,6 +1126,14 @@ <h4 id="s5.2.8-type-variable-names">5.2.8 Type variable names</h4>
<code class="prettyprint lang-java">FooBarT</code>).</li>
</ul>

<h4 id="s5.2.9-unnamed-variables">5.2.9 Unnamed variables</h4>

<p>The <code class="prettyprint lang-java">_</code> syntax for unnamed variables and parameters is
allowed wherever it is applicable. For example:</p>

<pre class="prettyprint lang-java">Predicate&lt;String&gt; alwaysTrue = _ -&gt; true;
</pre>

<a id="acronyms"></a>
<a id="camelcase"></a>
<h3 id="s5.3-camel-case">5.3 Camel case: defined</h3>
Expand Down Expand Up @@ -1232,7 +1255,7 @@ <h3 id="s6.2-caught-exceptions">6.2 Caught exceptions: not ignored</h3>
<pre class="prettyprint lang-java">try {
int i = Integer.parseInt(response);
return handleNumericResponse(i);
} catch (NumberFormatException ok) {
} catch (NumberFormatException _) {
// it's not numeric; that's fine, just continue
}
return handleTextResponse(response);
Expand Down