Java Basics (top)

Source: Internet
Author: User

1.Java syntax format: Any set of languages has its own grammar rules, Java is the same, since it is the rule, then know how to use the good.

The code is defined in the class, the class is defined by class, and the public class and class are distinguished.

The code is strictly case-sensitive, such as main and main are not the same;

Identifiers and keywords in Java;

Comments

The role of the 2.main method

Entrance to the program

Guarantee The independent operation of the program

Called by the JVM

3. Notes

Single-line comments////After the end of the bank all characters will be ignored by the compiler;

All characters between the multiline comment/*///* * are ignored by the compiler

Document Comment/** * * All characters between/** * * are ignored by the compiler, Java Special (for generating documents);

4.Java language Separators

The parting of a sentence means that the end of a word is like the period we use.

Curly braces {} denote a block of code, which is a whole, curly braces are used together

square brackets [] define arrays and access array elements when using

The parentheses () are widely used

Polka dots. Class/Object accesses its members (fields, methods) when used, etc.

Space splits the different parts of a statement without limiting the number of spaces

5.Java keywords

Abstract

Do

Implement

Private

This

Boolean

Double

Import

Protected

Throw

Break

Else

instanceof

Public

Throws

Byte

Extends

Int

Return

Transient

Case

False

Interface

Short

True

Catch

Final

Long

Static

Try

Char

Fianlly

Native

Strictfp

void

Class

Float

New

Super

Volatile

Continue

For

Null

Switch

While

Default

If

Package

Enum

Synchronized

Assert

Identifiers in 6.Java: custom names, such as: Class name, method name, variable name, and so on.

Naming rules:

(1) consists of letters, numbers, underscores, and $, and cannot begin with a number note: The letters here can also be Chinese, Japanese, etc.

(2) Case sensitive

(3) Do not use keywords and reserved words in Java

(4) Do not use the class name inside the Java API as your own.

Constants of 7.Java: (1) literals (2) constants: Fixed values in the program

Variables in 8.Java:

Concept of a variable: occupies a storage area in memory that has its own name (variable name) and type (data type).

Why do you define variables? It is used to keep constant of the same type and can be reused.

When using variables, pay attention to the scope of the variable (the definition starts at the end of the code block that defines it) and the initialization value.

member variables and local variables in 9.Java

Local variable: A variable that is not declared inside the body bracket of a class. Must be initialized before use; no default initialization value; The scope starts at the end of the definition to its block of code.

Member variable: Also known as a field or global variable. The scope is the entire class.

Data type of 10.Java

11. Most commonly used reference data type (string): string is not a basic data type, string is a class that represents a string

12. Basic type Conversion

The Boolean type is not convertible to other base data types.

Integer, character, and floating-point data are converted to each other in a mixed operation, and the following principles are followed when converting:

    small-capacity types can be automatically converted to large data types : byte,short,char→int→long→float→double

Byte,short,char do not convert to each other, they are first converted to int type when calculating.

  When a large data type is converted to a small-capacity data type, it is necessary to add a cast character, but may result in a decrease or overflow of precision, especially when used.

When there are many types of data blending operations, the system first automatically converts all data into the largest data type of the container and then calculates it.

Float type: default is double

Integer: The default is int

13.Java operator

An operator is a special symbol that represents the operation, assignment, and comparison of data in a number of ways:

Arithmetic operators

Assignment operators

Comparison operators

logical operators

Shift Operators

Java Basics (top)

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.