Java Basic syntax

Source: Internet
Author: User

1. Java is divided into three major systems:

Javase Java Platform Standard Edition,javame java Platform mini version java ee .

2.Java Basic Syntax :

Object: An object is an instance of a class that has state and behavior. For example, a dog is an object whose state is : color, name, variety, etc. Actions are : wagging the tail , barking , eating and so on.

class : A class is a template that describes the behavior and state of a class of objects.

Method: The method is the behavior, and a class can have multiple methods. Logical budgeting , data modification , and all actions are done in the method.

instance Variables : Each object has a unique instance variable, and the state of the object is determined by the value of these instance variables.

C:> Javac Myfirstjavaprogram.java C: >java myfirstjavaprogram< in cmd parsing java code >

3. When writing java programs, the following points should be noted:

Case-sensitive: Hello and Hello are different.

Class Name: for all classes, the first letter of the class should be capitalized. If there are several words, the first letter of each word must be capitalized, for example : Myfirstjavaprogram.

Method Name: All method names begin with a lowercase letter. If there are several words, the first letter of each subsequent word is capitalized.

Source files: The source file name must be the same as the class name.

Main method Entry: all java programs are executed by the public static void Main (String [] args) method.

4. With regard to Java identifiers, the following points need to be noted :

all identifiers should be in the alphabet ( A-Z or A- z) dollar symbol ($), or underscore (_) begins.

the first character can then be a combination of any character. The keyword cannot be used as an identifier.

identifiers are case-sensitive. Legal identifiers : Age, $salary, _value,_1_value .....

illegal identifier : 123abc,-salary

    1. Java modifier

Accessibility modifier : default,public,protected,private

non-accessible cosmetic hair : FINAL,ABSTRACT,STRICTFP.

6.java Variables

Local Variables ; class Variables ( static variable ); member Variables ( non-static variable )

7.java Arrays

An array is an object stored on a heap and can hold multiple variables of the same type.

8.java Enumeration

Java5.0 introduces enumerations, which limit variables to pre-set values only. Using enumerations can reduce the number of bugs in your code .

Note : enumerations can be declared individually or declared inside a class. Methods , variables , constructors , or definitions in enumerations.

Key words

Describe

Abstract

Abstract methods, adornments of abstract classes.

Assert

Asserts whether the condition is satisfied.

Boolean

Boolean Data types

Break

Jump out of the bad or label code Snippet

Byte

8-bit ( bit ) signed data type

Case

a condition for a Switch statement

Catch

using catch exception information with try

Char

16-bit ( bit ) Unicode character data type

Class

Defining classes

Const

Not used

Continue

Do not execute the remainder of the loop body

Default

Default Branch in the Switch statement

Do

Loop statement, the loop body is executed at least once

Double

64-bit ( bit ) double precision floating point number

Else

The IF condition does not execute when the branch is executed

Extends

Represents a class that is a subclass of another class

Final

Indicates that a value cannot be changed after it has been initialized.

A table method cannot be overridden , or a class cannot have subclasses.

For

For Loop statement

Finally

Execute code whether or not an exception occurs

Float

32-bit(bit) single-precision floating-point number

Goto

Not used

Implements

Indicates that a class implements an interface

Import

Import class

instanceof

To test whether an object is an instance of a class

Int

32-bit ( bit ) integer number

Interface

Interface , an abstract type , with only the definition of methods and constants

Long

number of decimal integers

Native

Represents methods implemented in non- Java code

New

Assigning an instance of a new class

Package

A series of related classes make up a package

Private

Represents a private field , or method, etc. , accessible only from within the class

Public

Represents common properties and methods

Protected

Indicates that a field can only be accessed through a class or subclass.

or other classes within the same package.

Return

Method return value

Short

number of short integers

Static

Represents at the class level definition , All instances are shared

Strictfp

Floating-point numbers apply to more stringent specifications

Super

Represents a base class

Switch

SELECT statement

Synchronized

A block of code that represents the same time that can be accessed only by one thread

This

Represents invoking the current instance or calling another constructor

Throw

Throw exception

Throws

Defining exceptions that a method might throw

Transient

Modify fields that do not serialize

Try

Represents a code block to do exception handling or a finally mate to indicate whether throwing an exception executes The code in the finally

void

The tagged method does not return any values

Volatile

Tag fields may be accessed by multiple threads at the same time without synchronizing

While

While Loop

Java Basic syntax

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.