Home  >  Article  >  Java  >  java syntax basics

java syntax basics

伊谢尔伦
伊谢尔伦Original
2016-12-05 09:42:181170browse

Keyword Key

Keyword                                                                                                                                                                             mean break Jump out early A block

byte One of the basic data types, byte type

catch Used in exception handling to catch exceptions

char One of the basic data types, character type

class Class

const Reserved keywords, no Specific meaning

continue Return to the beginning of a block

default Default, for example, used in switch statements to indicate a default branch

do Used in do-while loop structures

double One of the basic data types, Double precision floating point type

else is used in conditional statements to indicate the branch when the condition is not true

enum Enumeration

extends Indicates that one type is a subtype of another type. Common types here include classes and interfaces

enum

extends Indicates that a type is a subtype of another type. Common types here include classes and interfaces.

final is used to describe the final attributes, indicating that a class cannot derive a subclass, or that member methods cannot be overridden. Or the value of the member field cannot be changed.

finally is used to handle exceptions and is used to declare a statement block that will basically be executed.

float is one of the basic data types, single-precision floating point number type.

extends indicates a type. Is a subtype of another type. Common types here include classes and interfaces.

for is a guide word for a loop structure.

goto is a reserved keyword and has no specific meaning.

if is a guide word for conditional statements.

implements indicates a class. Implements the given interface

import Indicates that you want to access the specified class or package

instanceof Used to test whether an object is an instance object of the specified type

int One of the basic data types, integer type

interface Interface

long One of the basic data types, the long integer type

native is used to declare that a method is implemented by a computer-related language (such as C/C++/FORTRAN language)

new is used to create a new instance object

package

private An access control method: private mode

protected An access control method: protected mode

public An access control method: shared mode

return Return data from member methods

short One of the basic data types, The short integer type

static indicates that it has static attributes

strictfp is used to declare that the FP_strict (single-precision or double-precision floating point number) expression follows the IEEE 754 arithmetic specification

super indicates the reference of the parent type of the current object or the constructor of the parent type

switch The guide word for the branch statement structure

synchronized Indicates that a piece of code needs to be executed synchronously

this Reference pointing to the current instance object

throw Throws an exception

throws Declares all that need to be thrown in the currently defined member method Exception

transient Declaring a member field that is not serialized

try Trying a program block that may throw an exception

void Declaring that the current member method has no return value

volatile Indicating that two or more variables must change synchronously

while Used in loop structures

Identifier

is actually a noun customized in the program. For example, class name, variable name, function name. Contains
0-9, a-z, $, _ ;
Note:

1. Numbers cannot begin
2. Keywords cannot be used

Constant

Amounts that will not change during operation will be replaced after compilation A magic number

Variable

is actually a storage space in memory used to store constant data.

Function: Convenient for calculations. Because some data are uncertain. So determine the noun and storage space of the data.

Features: Variable space can be reused.

Scope and lifetime of variables

Scope of variables:

Scope starts from the position where the variable is defined and ends with the pair of braces where the variable is located;

Life cycle:

Variable starts from the position where it is defined It lives in memory from the beginning;

The variable disappears from memory when it reaches its scope;

Data types

Basic data types

byte, short, int, long, float, double, char , boolean

reference data type

array, class, interface

levels from low to high are

byte, char, short (flat)-->int-->float-->long-- >double

automatic type conversion

from low level to high level, the system automatically converts;

arithmetic symbol

arithmetic operator

+ - * / % Any integer modulo 2 is either 0 or 1, the switch can be implemented Operation

Assignment operator

= ,+= , -= , *= ,/= , %=

Comparison operator

Features: The characteristics of this operator are: the result after the operation is either true or false

logical operator

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn