Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35730
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Is You Is Or Is You Ain't A Literal? |
| Date | 2016-10-05 20:21 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <nt45e5$vcr$1@gioia.aioe.org> (permalink) |
| References | <literal-20161005222352@ram.dialup.fu-berlin.de> |
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 comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: Is You Is Or Is You Ain't A Literal? Arne Vajhøj <arne@vajhoej.dk> - 2016-10-05 20:21 -0400
csiph-web