Java Learning notes (Getting started) _java basic syntax _java

Source: Internet
Author: User
Tags comments documentation reserved
Preface
After learning the first Java program, then the system to learn java. First from the basic grammar, you can also understand the grammar of English or Chinese grammar, but everyone has their own characteristics and differences. Learning programming is also a learning process in a programming language. When we learn English, we all say, if you want to learn good English must say, then you must write when learning programming. Programming is nothing more than a process of writing code, the first is your heart to have a foundation, there is no basis for how to write it, like a good article, no good writing is not written out. Good writing not only depends on accumulation, but also on creation, so is programming. Java is an object-oriented language, in the process of writing code, the most contact is the class and interface, as well as the following properties and methods. Then in the process of learning we will continue to accumulate important classes and methods, so write the program will be convenient and quick. Here's how to start learning Java's basic syntax:

The focus of the study is as follows
• Mastering the definition rules of identifiers
• Understand commonly used reserved words and delimiters
• Mastering the use of a variety of simple data types
• Mastering the use of operators and expressions
• Master Java program simple input and Output methods

1, Java designator
Used to indicate a variable, method, or class name. The rules are defined as follows:
• Only letters, numbers, underscores, and dollar characters can be used.
• Can only begin with letters, underscores, and dollar characters. That is, you cannot start with a number.
• Strictly case-sensitive, with no length limitations. But it is better not to be too long and not necessary.
• Should have a specific meaning. It is best to use a related word, such as an addition method, then it is best to write: Add (INTA,INTB).

2, java reserved words
These reserved words are often used in programming.

3. Java Separator
• With: spaces, parentheses, curly braces, semicolons, and so on.
• Each statement ends with a semicolon, whether one line or multiple lines. A block is a number of statements contained within {}, and blocks can be nested. Whitespace is inserted in the middle of the code: it consists of one or more spaces, or it can consist of one or more tab spaces with multiple blank lines.

4. Java Annotations
Comments are used to make a specification of the written code, so that not only organized, others will be able to see, but also for future development to bring convenience.
(1) Single line://... For a line of code to comment
(2) Multiline:/* used to annotate multiple lines of code
...
*/
(3) Documentation Note: Use the Javadoc tool to remove information from source code and documentation comments and convert it to an HTML file
/**
*...
*/
5. Java Data type
A data type is the type that precedes the definition of a property or method, such as Inta;int is a data type that represents an integer variable. The data types in Java are divided as follows:


6. Java Operators and Expressions
1. Arithmetic operator: Plus + minus-multiply * divide/seek% gaga + + minus--Take back--
2. Assignment Operator: =
3. Relational operator: ><>=<===!=
4. Logical operator: True,false
5. Conditional operator:? :

7, Java input and output
System.in represents an input stream; System.out represents the output.
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.