In Java compiler,which type can be defined as identifier ( ID ) or Keyword (reserved word)?

后端 未结 2 1346
夕颜
夕颜 2021-01-27 04:59

I have a simple question:
In Java Compiler, Which type of method or variables can be defined as identifier (ID) or Keyword (reserved word)?

For following example, ID

2条回答
  •  离开以前
    2021-01-27 05:34

    The Java keywords are part of the language, and are documented in the Java Language. You cannot use a keyword as an identifier . const and goto are reserved keywords, but not implemented. true, false, and null are literals; you still cannot use them as identifiers but they are not keywords.

    From the linked Java tutorial, the keywords are

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

    1not used

    2added in 1.2

    3added in 1.4

    4added in 5.0

提交回复
热议问题