Introduction to Java Tutorial (iii) Basic syntax (1)

Source: Internet
Author: User
Tags lowercase modifiers

# # #JAVA基础语法 # #

1. Keywords: words that are given a specific meaning by the Java language (the letters that make up the keywords are all lowercase)

1) keywords to define the data type

class, interface, Byte, short, int, long, float, double, char, boolean, void

2) used to set the data type worth the keyword

True, FALSE, NULL

3) keywords to define Process Control

If, else, switch, case, default, while, do, for, break, continue, return

4) keyword used to define access rights modifiers

Private, protected, public

5) Keywords for defining classes, functions, variable modifiers

Abstract, final, static, synchronized

6) keywords to define the relationship between classes and classes

Extends, implements

7) Used to define instance and reference instances, and to determine the keywords

New, this, super, instanceof

8) keywords for exception handling

Try, catch, finally, throw, throws

9) keywords for the package

Package, Import

10) Other modifier keywords

Native, strictfp, transient, volatile, assert

2. Identifier: A sequence of characters used to name a class, an excuse, a method, a variable, etc.

(PS: Must be in English uppercase and lowercase letters, numeric characters, ¥ and _)

Note: You cannot start with a number; it cannot be a keyword in Java; Java is strictly case-sensitive

For example, when we define a variable, the name is what can not be used

3. Note: Text used to illustrate the program

1) Single-line comment://Comment text

2) Multiline Comment:/* Comment Text */

3) Document Comment:/** Note text */

In order to have a good habit in the future development road, the beginner writes the program best to write the comment before writes the code.

4. Constant: Its value cannot be changed during program execution

The contents of a string constant enclosed in double quotation marks
integer constant all integers
Decimal constant All Decimals
The contents of a character constant enclosed in single quotation marks
Boolean constants are more specific, only true and false
Empty constant Null (part of the array explained)

5. Variable: The amount of the value that can change within a range during the execution of a program

Variable name of data type = initialization value;
Note: The format is fixed, remember the format, Status quo

6. Data type: The Java language is a strongly typed language that defines specific data types for each type of data, with memory spaces that are always allocated in memory of different sizes

Considerations for Using Variables:
Scope: The variable is defined in the curly braces, which range is the scope of the variable. Two variables of the same name cannot be defined in the same scope.
Initialization value: No initialization value can be used directly
It is recommended that you define only one variable on a line, but you can define multiple, but do not recommend

Examples:

System.out.println (' a ');
System.out.println (' a ' + 1);
System.out.println ("Hello" + ' a ' + 1);
System.out.println (' A ' +1+ "Hello");
System.out.println ("5+5=" +5+5);

System.out.println (5+5+ "=5+5");

Observe the above output results

# # # #END # #

Related articles:

Java Starter System Tutorial (i) Configuring the Java Development environment

Introduction to Java Tutorial (ii) installation using Eclipse

Related Article

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.