Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35730 > unrolled thread
| Started by | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| First post | 2016-10-05 20:21 -0400 |
| Last post | 2016-10-05 20:21 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.java.programmer
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Is You Is Or Is You Ain't A Literal? Arne Vajhøj <arne@vajhoej.dk> - 2016-10-05 20:21 -0400
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2016-10-05 20:21 -0400 |
| Subject | Re: Is You Is Or Is You Ain't A Literal? |
| Message-ID | <nt45e5$vcr$1@gioia.aioe.org> |
On 10/5/2016 5:30 PM, Stefan Ram wrote:
> Is »2« a literal?
>
> I think JLS 3.10.1 says "yes".
>
> But there also is a test method:
>
> javax.lang.model
>
> Enum SourceVersion
>
> public static boolean isKeyword( java.lang.CharSequence s )
>
> Returns whether or not s is a keyword or literal in the latest
> source version.
>
> Parameters: s - the string to check
>
> Returns: true if s is a keyword or literal, false otherwise.
>
> So,
>
> public final class Main
> { public static void main( final java.lang.String args[] )
> { java.lang.System.out.println
> ( javax.lang.model.SourceVersion.isKeyword( "2" )); }}
>
> false
>
> So, »2« is not a literal?
2 is a literal.
The documentation is bad/misleading.
A quick glance in the source code reveals what "or literal"
means.
It is only the 3 "name like" literals: null, true and false.
Arne
Back to top | Article view | comp.lang.java.programmer
csiph-web