Java Basic Syntax Summary 1

Source: Internet
Author: User
Tags null null switch case true true try catch java keywords

I. Identifiers and Character sets

The Java language specifies that identifiers begin with a letter, an underscore "_" or a dollar sign "$", followed by a sequence of characters that can be followed by a number, letter, underscore, or dollar sign. Java identifiers are case-sensitive, have no length limit, and can be given an arbitrary length name for an identifier, but the keyword cannot be used as an identifier. To enhance the readability of the program, Java makes the following conventions:

1. Classes, interfaces: Nouns are usually used, and the first letter of each word is capitalized

2. Method: Usually use verbs, lowercase letters, and then separate each word with uppercase letters

3. Constants: All uppercase, the words are separated by underscores

4. Variables: Usually use nouns, lowercase letters, followed by uppercase letters to separate each word, avoid using the $ symbol.

The Java language uses the international character set (Unicode). The Unicode character set defines a set of international standard character sets. The usual ASCII code is 8 bits, while each character in the Unicode character set occupies 16 bits, or 2 bytes, and the entire character set consists of 65,336 characters, compatible with ASCII, and the 256 characters that precede the Unicode character set are ASCII codes. In addition to representing 256 ASCII codes, Unicode can also represent Chinese characters, Latin, Greek letters, Korean, and so on.

Summary of Java Identifiers: 1. Consist of letters, numbers, _ or $, which cannot begin with a number; 2. Strictly case-sensitive; 3. Unlimited length

Second, the key word

A list of common Java keywords is as follows:

Key words

Meaning

Abstract

It is used in the declaration of a class to indicate that a class cannot be instantiated, but can be inherited by other classes. An abstract class can use abstract methods, and abstract methods do not need to be implemented, but they need to be implemented in subclasses

Boolean

Boolean type, only true or false

Break

Stop, and jump out of this layer loop

Byte

8bit (bit), that is, 8 x 1/0 means, binary

Case

Used to define a set of branch selections, and if a value is the same as the value given in a switch, it is executed from that branch.

Catch

Used to declare a block that runs when a run-time error or a non-runtime exception occurs in a try statement block.

Char

Used to define a character type

Class

Class

Const

In Java, the const is used as a reserved word for expansion, with the same reserved word for expansion and Goto. You can use the final keyword. Final can also be used to declare a method or class that cannot be inherited by a method or class that is declared final. General c is const corresponding to Java with final

Continue

Used to interrupt the current loop process, starting at the end of the current loop, and if followed by a label, start execution from the label's corresponding location.

Default

In conjunction with switch and case, the output or the statement following the default is not found when a match is located.

Do

Used to declare a loop in which the end condition of the loop can be set by the while keyword

Double

Used to define a variable of type double

Else

If the condition of the IF statement is not satisfied, the statement executes.

Extends

extends inherits class X by Extend class Y to add functionality, or adding a variable, or adding a method, or overriding a method of Class Y. An interface extends another interface to add a method.

False

It's fake.

Final

A keyword for a Java language. You can define only one entity at a time, and you cannot change it or inherit it later. More strictly speaking: A final modified class cannot be quilt-like, a final modified method cannot be overridden, and a final modified variable cannot change its initial value.

Finally

Used to execute a piece of code regardless of whether there are exceptions or run-time errors in the Try statement defined earlier.

Float

Used to define a floating-point variable

For

Used to declare a loop. Programmers can specify the statements to loop, introduce conditions and initialize variables.

Goto

Java does not provide a goto statement, although it is a Java keyword, but only used in the C language

If

A keyword in the Java programming language that is used to generate a conditional test, and if the condition is true, execute the IF statement.

Implements

A keyword in the Java (TM) programming language, which is optional in the declaration of the class, to indicate the interface that the current class implements.

Import

A keyword in the Java (TM) programming language that indicates a class or entire package to be referenced at the beginning of the source file, so that you do not have to add the package name when you use it.

Instaceof

A two-operand Java (TM) language keyword that is used to test whether the run-time type of the first parameter is compatible with the second parameter.

Int

A keyword in Java (TM) used to define an shaping variable

Interface

A keyword in Java (TM) used to define a series of methods and constants. It can be implemented by class by implements keywords.

Long

Used to define a long type of variable

Native

Local methods.

New

Used to create a new method

Null

When the string type is not assigned a value, the value of the variable is null

Package

The meaning of the package

Private

Used in the sound of a method or variable. It means that the method or variable can only be accessed by other elements of the class.

Protected

Used in declarations of methods and variables, which indicates that the method or variable can only be accessed by elements in the same class, in subclasses, or in classes within the same package.

Public

Used in declarations of methods and variables, which means that the method or variable can be accessed by elements in other classes.

Return

Used to end the execution of a method. It can be followed by a value that is required in a method declaration.

Short

Used to define a variable of type short.

Static

Used to define a variable as a class variable. class maintains only a copy of a class variable, regardless of how many instances of the class are currently present. "Static" can also be used to define a method as a class method. A class method is called by a class name instead of a specific instance, and only class variables can be manipulated.

Super

Parent class

Switch

is a SELECT statement to use with Case,default,break.

Synchronized

Thread synchronization

This

An instance of the class used to represent the occurrence of it. This can be used to access class variables and class methods.

Threadsafe

Throw

Allows the user to throw an exception object or any object that implements Throwable

Throws

It is used in the declaration of the method to illustrate which exceptions are not handled, but rather to be submitted to a higher level of the program.

Transient

Used to indicate that a domain is not part of the serialization of the object. When an object is serialized, the value of the transient variable is not included in the serialized representation, whereas the non-transient variable is included.

True

It's true

Try

Used to define a block that may throw an exception statement. If an exception is thrown, an optional catch statement block will handle the exception thrown in the try statement block. At the same time, a finally statement block is executed, regardless of whether an exception is thrown.

Void

The method declaration in the Java language illustrates that this approach does not have any return value. "Void" can also be used to denote a statement without any function.

Volatile

It is used in the declaration of a variable to indicate that the variable is asynchronously modified by several threads running concurrently.

While

Used to define a looping statement that executes repeatedly. The exit condition of the loop is part of the while statement.

The categories are as follows:

1. Access control: Private protected protected public

2. Class, method, and variable modifiers abstract declares abstract class extends, inherits final ultimate, immutable implements implements interface interface native local new, creates static static Stric TFP Strict, accurate synchronized thread, synchronous transient transient volatile volatile

3. Program Control statement break jumps out of the loop continue continue return returns do run while loop if else inverse for instanceof Instance switch case Returns the result of default in the switch Default

4. Error handling catch handling exception finally there is no exception to execute throw throws an exception object

Throws declares an exception that may be thrown by a try catch exception

5. Package related import into package packages

6. Basic Type Boolean Boolean byte char character type double double float floating-point int integer long Long integer short shorter integer null null true True False

7. Variable reference Super Parent class, superclass this class void no return value

Note: 1. All Java keywords are lowercase 2, goto and const are reserved keywords, not used in Java 3, STRICTFP and volatile is not used; sizeof, then is not a keyword.

4, True,false,null is not the key word in the strict sense, but literals.

(ext: http://www.cnblogs.com/doit8791/archive/2012/05/26/2519545.html)

Java Basic Syntax Summary 1

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.