Is main a valid Java identifier?

后端 未结 12 2002
广开言路
广开言路 2020-12-23 02:48

One of my kids is taking Java in high school and had this on one of his tests:

Which of the following is a valid identifier in Java?

a. 123

12条回答
  •  猫巷女王i
    2020-12-23 03:12

    main is perfectly valid because it, from the docs:

    1. Is a "sequence of Java letters and Java digits, the first of which is a Java letter"
    2. Is not a keyword
    3. Is not a boolean literal i.e. "true" or "false"
    4. Is not null literal

提交回复
热议问题