Java keywords and identifiers

Source: Internet
Author: User

Java keywords and identifiers

First, Java keywords

    1. 1. Java keyword definition

Java's keywords have special meanings for Java compilers, which are used to represent a data type, or to represent the structure of a program, and the keyword cannot be used as a variable name, method name, class name, package name, or parameter.

    1. 2. features of the Java keyword

All letters in the keyword are lowercase.

    1. 3. Java keyword classification
    • Keywords to define the data type

class interface byte short int long float

Double char Boolean void

    • Keywords to define data type values

True false null

    • Keywords to define Process Control

If else switch case default while

Do for break continue return

    • Keywords used to define access rights modifiers

Private protected public

    • Keywords for defining classes, functions, variable modifiers

Abstract final static synchronized

    • Because the keyword that defines the relationship between a class and a class

Extends implements

    • Used to define instance and reference instances, and to determine the keywords

New This super instanceof

    • Keywords for exception handling

Try Catch finally throw throws

    • Keywords for the package

Package Import

    • Other modifier keywords

Native STRICTFP transient volatile assert

Note:while const and Goto do not have specific meanings in Java, Java also lists them as keywords because const and goto are keywords for some other computer languages.

Second, Java identifiers

    1. 1. Java identifier definition

Some names that you customize in your program, which contain the class name, package name, method, variable name, and field.

    1. 2. naming rules for Java identifiers:
    • identifiers cannot be keywords;
    • Identifiers can contain letters, numbers 0-9, underscores (_), or dollar signs ($);
    • The first character of an identifier cannot be a number;
    • The identifiers are strictly case-sensitive, and the hump naming method is used;

remark:   when naming, improve reading, try to make sense

    1. 3. the name specification in Java:
    • Package Name: When multiple words are composed, all letters are lowercase;

such as: xxxyyyzzz

    • Class name and Interface name: When multiple words are composed, the first letter of all words is capitalized;

such as: xxxyyyzzz

    • Variable name and function name: When multiple words are composed, the first letter is lowercase, and the first letter of each word begins with the second word capitalized;

such as: xxxyyyzzz

    • Constant name: All letters are capitalized. For multiple words, each word is connected with an underscore.

such as: xxx_yyy_zzz

Java keywords and identifiers

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.