Lexical Structure (JDK8-jsl)
in JavaCo-De with 0 comment

Lexical Structure (JDK8-jsl)

in JavaCo-De with 0 comment

Unicode

Unicode Escapes

UnicodeInputCharacter:
    UnicodeEscape
    RawInputCharacter
UnicodeEscape:
    \ UnicodeMarker HexDigit HexDigit HexDigit HexDigit
UnicodeMarker:
    u {u}
HexDigit:
    (one of)
    0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
RawInputCharacter:
    any Unicode character

Special Chars

Identifiers

Identifier:
    IdentifierChars but not a Keyword or BooleanLiteral or NullLiteral
IdentifierChars:
    JavaLetter {JavaLetterOrDigit}
JavaLetter:
    any Unicode character that is a "Java letter"
JavaLetterOrDigit:
    any Unicode character that is a "Java letter-or-digit"

Keywords, Boolean Literals, Null Literals

abstract   continue   for          new         switch
assert     default    if           package     synchronized
boolean    do         goto         private     this
break      double     implements   protected   throw
byte       else       import       public      throws
case       enum       instanceof   return      transient
catch      extends    int          short       try
char       final      interface    static      void
class      finally    long         strictfp    volatile
const      float      native       super       while

Integer

IntegerLiteral:
    DecimalIntegerLiteral
    HexIntegerLiteral
    OctalIntegerLiteral
    BinaryIntegerLiteral
DecimalIntegerLiteral:
    DecimalNumeral [IntegerTypeSuffix]
HexIntegerLiteral:
    HexNumeral [IntegerTypeSuffix]
OctalIntegerLiteral:
    OctalNumeral [IntegerTypeSuffix]
BinaryIntegerLiteral:
    BinaryNumeral [IntegerTypeSuffix]
IntegerTypeSuffix:
    (one of)
    l L

Floating

FloatingPointLiteral:
    DecimalFloatingPointLiteral
    HexadecimalFloatingPointLiteral
DecimalFloatingPointLiteral:
    Digits . [Digits] [ExponentPart] [FloatTypeSuffix]
    . Digits [ExponentPart] [FloatTypeSuffix]
    Digits ExponentPart [FloatTypeSuffix]
    Digits [ExponentPart] FloatTypeSuffix
ExponentPart:
    ExponentIndicator SignedInteger
ExponentIndicator:
    (one of)
    e E
SignedInteger:
    [Sign] Digits
Sign:
    (one of)
    + -
FloatTypeSuffix:
    (one of)
    f F d D

Boolean

ture/ false

Character

String

package testPackage;
class Test {
    public static void main(String[] args) {
        String hello = "Hello", lo = "lo";
        System.out.print((hello == "Hello") + " ");            //true
        System.out.print((Other.hello == hello) + " ");        //true
        System.out.print((other.Other.hello == hello) + " ");  //true
        System.out.print((hello == ("Hel"+"lo")) + " ");       //true, computed at compile
        System.out.print((hello == ("Hel"+lo)) + " ");         //fasle, computed as runtime
        System.out.println(hello == ("Hel"+lo).intern());      //true, use constant pool
    }
}
class Other { static String hello = "Hello"; }

Escapes

EscapeSequence:
    \ b (backspace BS, Unicode \u0008)
    \ t (horizontal tab HT, Unicode \u0009)
    \ n (linefeed LF, Unicode \u000a)
    \ f (form feed FF, Unicode \u000c)
    \ r (carriage return CR, Unicode \u000d)
    \ " (double quote ", Unicode \u0022)
    \ ' (single quote ', Unicode \u0027)
    \ \ (backslash \, Unicode \u005c)
    OctalEscape (octal value, Unicode \u0000 to \u00ff)
OctalEscape:
    \ OctalDigit
    \ OctalDigit OctalDigit
    \ ZeroToThree OctalDigit OctalDigit
OctalDigit:
    (one of)
    0 1 2 3 4 5 6 7
ZeroToThree:
    (one of)
    0 1 2 3

Null

Separators (Punctuators)

(   )   {   }   [   ]   ;   ,   .   ...   @   ::

Operators

=   >   <   !   ~   ?   :   ->
==  >=  <=  !=  &&  ||  ++  --
+   -   *   /   &   |   ^   %   <<   >>   >>>
+=  -=  *=  /=  &=  |=  ^=  %=  <<=  >>=  >>>=

Ref.

Lexical Structure
man

Responses