<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
Hi Anton,
<div><br>
</div>
<div>Thanks for your email. It is perhaps a little confusing, but chapter 3 is talking about the lexical structure of the language, i.e. the tokens. So, 3.12 is talking about the syntactic tokens that we call the operators. (Perhaps more precisely, the operator
 tokens.)</div>
<div><br>
</div>
<div>Chapter 15, in contrast, is talking about the various categories of expressions. It uses “operator” in a quite different sense (really it is talking about operator
<u>expressions</u>). For example in 15.5, when talking about errors in casts:</div>
<div><br>
</div>
<div>In a cast, when the actual class of the object referenced by the value of the
<div>operand expression is not compatible with the target type specified by the <b>
cast</b></div>
<div><b>operator</b> (§5.5, §15.16); in this case a ClassCastException is thrown.</div>
<div><br>
</div>
<div>Note the reference to the cast operator here (in bold), which isn’t in the list of 3.12 either.</div>
<div><br>
</div>
<div>So, when reading chapter 15, one should have this categorisation in mind (from 15.2):</div>
<div><br>
</div>
<div>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
Expressions can be broadly categorized into one of the following syntactic forms:</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Expression names (§6.5.6)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Primary expressions (§15.8 - §15.13)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Unary operator expressions (§15.14 - §15.16)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Binary operator expressions (§15.17 - §15.24, and §15.26)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Ternary operator expressions (§15.25)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• Lambda expressions (§15.27)</p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Times; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
• <span style="font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 9px; line-height: normal; font-family: Courier; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;">
switch</span> expressions (§15.28)</p>
</div>
<div><br>
</div>
<div>So, the category of unary operator expressions includes cast expressions too. In that spirit, the category of binary operator expressions includes the instanceof expressions, and hence in the context of chapter 15, we can speak of instanceof as a (binary)
 operator.</div>
<div><br>
</div>
<div>Hope this helps,</div>
<div>Gavin</div>
<div><br>
<blockquote type="cite">
<div>On 31 May 2023, at 11:14, Anton.Dil <anton.dil@open.ac.uk> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">Greetings,<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">I have a query about which tokens should be considered operators.<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">Many sources say that instanceof is an operator, including the JLS, e.g. at<span class="Apple-converted-space"> </span><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.20.2" style="color: rgb(5, 99, 193); text-decoration: underline;">https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.20.2</a><o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">However, instanceof is not included in the list of operators here<span class="Apple-converted-space"> </span><a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-3.html#jls-3.12" style="color: rgb(5, 99, 193); text-decoration: underline;">https://docs.oracle.com/javase/specs/jls/se17/html/jls-3.html#jls-3.12</a><o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">Which is correct? Should instanceof be in the operators list?<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><o:p> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;">Regards,<o:p></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;"><br>
Anton</span></div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>