JAVA syntax-based identifiers and keywords

Source: Internet
Author: User

JAVA syntax-based identifiers and keywords
1. The variable name, method name, class name, and object name in the identifier JAVA are all identifiers. During program writing, the identifiers must be uniquely identified for identification and reference. The naming rules for identifiers in Java are as follows: they can contain uppercase and lowercase letters, numbers, underscores, and dollar symbols in any order. It cannot start with a number. It cannot be a reserved keyword in Java. There is no length limit, but it is case sensitive. For example, Hello and hello are different identifiers. 2. Like other languages, Java also has many reserved keywords (that is, they have special meanings in Java), such as public and break. These reserved keywords cannot be used as identifiers. We don't need to memorize the keywords. knowing this is enough. If you accidentally use these keywords, the compiler can tell us this error. The following table lists the Java keywords: abstract boolean break byte case catchchar class continue default do doubleelse extend false final finally floatfor if implement import instanceof intinterface long native new null partition protected public return short limit switch between this throw limit true try void volatile ehilegoto const note: in Java Use keywords such as gogo and const, but still cannot use goto and const as variable names. Iii. Naming Conventions for Java identifiers from the perspective of Java syntax, the names are random, but in our daily programming process, to improve code readability, maintainability, and debugging convenience, we recommend that you name your code in a case-sensitive manner and follow the following rules: package name: in lowercase English words, it is better to have a hierarchy, such as com. hq. core. Class Name and Interface Name: Usually a noun, represented by one or more English words. The first letter of each word is capitalized, such as Color and FileInputStream. Method Name: it is usually a verb. The first letter of the first word is lowercase. If there are other words, the first letter is capitalized from the second word, such as main (), draw (), setColor (). Variable name or object name: Same as the method case-sensitivity rules. Constant name: declared as public static final. All letters are uppercase. Words are separated by underscores (_), for example, MAX_VALUE.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.