Lecture 1: Basic Java syntax (1)
Promote your career, do not let your career push you. -- Einstein
Description: object, identifier, and keyword.
Java, as a language, must have its own syntax rules. One of the keys to learning programming languages is to learn grammar rules, write statements that conform to the syntax rules, and control the computer to complete various tasks. Written according to the syntax rules of the programming language, the set of code that completes a function can be called a program.
1. Object ):
An important feature of Java is Object Oriented, which is relative to Process Oriented.
The process-oriented approach describes this process:
The object-oriented approach describes this process:
When we take the refrigerator as an object, the problem becomes very simple. There is a way in the refrigerator to take milk. You call this method, and the return value of this method is a cup of milk. It is equivalent to a smart refrigerator.
Object-Oriented Programming Language regards everything as an object: Everything is an object.
2. identifier (Indentifier)
Java components such as class name, Object Name, method name, and constant name must be named. The names of these components are called Identifiers (Indentifier ).
Valid identifiers have naming rules:
1. It must start with a letter, dollar sign, or underscore. The number cannot start
2. The first character can be any combination of numbers, letters, dollar signs, and underscores of any length.
3. Java keywords and reserved words cannot be used as identifiers.
4. identifiers are case sensitive. Z and z are two different identifiers.
5. Unicode characters are treated as common letters.
Unicode is an important universal character encoding standard for interaction and display. It covers the languages of the United States, Europe, Middle East, Africa, India, Asia and the Pacific, as well as ancient and professional symbols.
For details about Step 5:
Public class text {public static void main (String [] args) {String Yangjiang = Yangxi No. 1 Middle School; System. out. println (Yangjiang );}}
The above code successfully printed the word "Yangxi No. 1 Middle School.
3. keywords)
Like all programming languages, Java has a set of built-in keywords that cannot be used as identifiers. There are 50 keywords in Java SE6 ):
Abstract |
Continue |
For |
New |
Switch |
Assert |
Default |
Goto |
Package |
Synchronized |
Boolean |
Do |
If |
Private |
This |
Break |
Double |
Implements |
Protected |
Throw |
Byte |
Else |
Import |
Public |
Throws |
Case |
Enum |
Instanceof |
Return |
Transient |
Catch |
Extentds |
Int |
Short |
Try |
Char |
Final |
Interface |
Static |
Void |
Class |
Finally |
Long |
Strictfp |
Volatile |
Const |
Float |
Native |
Super |
While |
These words share the same characteristics: they are all in lowercase and cannot be used as identifiers. Instanceof is the connection of instance of, and strictfp is the connection of strict float point
There are three words that seem like keywords, but they are not the key stuff. They are the literal value (literal). The literal value concept will be discussed later.
True Boolean nominal value |
False Boolean nominal value |
Null literal value |