Re-walk Java--step 2

Source: Internet
Author: User
Tags control characters modifiers java keywords

Java Basic Syntax (i)

1.java Basic data types

Byte:1 bytes, 8bit signed data type
Boolean:2 bytes, 16bit boolean value
Char:2 byte, 16bit Unicode character type
Int:4 bytes, 32bit Integer data type
Short:2 bytes, 16-bit Short integer digits
Long:8 bytes, 64-bit integer digits
Float:4 bytes, 32-bit single-precision floating-point number
Double:8 bytes, 64-bit double-precision floating-point number

2.java identifiers

Java class names, variable names, method names are called Java identifiers, about Identifiers:

All identifiers should start with a letter, underscore, dollar symbol, and identifiers must not start with a number
Can be any character after the first character
Keyword cannot be used as an identifier
Identifier Sensitive case
Legal Example: $123,ADSDS12
Illegal instance: 1dsad,public
3.java variables
There are several types of variables in Java
Member Variable (non-static)
Local variables
Class variable (static)
About a class variable can use the variable value only by using the class name, and no instance calls the class variable one SAID.
4.java keywords

Meaning
Abstract Indicates that the class or Member method has an abstract property
Assert Used for program debugging
Boolean One of the basic data types, Boolean type
Break Jump out of a block early
Byte One of the basic data types, byte type
Case Used in a switch statement to represent one of the branches
  
Catch Used in exception handling to catch exceptions
Char One of the basic data types, character types
Class Class
Const Reserved keywords, no specific meaning
Continue Back to the beginning of a block
Default default, for example, in a switch statement, indicating that a default branch
Do Used in the DO-WHILE loop structure
Double One of the basic data types, double-precision floating-point number types
Else Used in a conditional statement to indicate a branch when the condition is not true
Enum Enumeration
Extends Indicates that one type is a subtype of another type, where the common types have classes and interfaces
Final Used to describe the final attribute, indicating that a class cannot derive a subclass, or that a member method cannot be overridden, or that the value of a member field cannot be changed
Finally Used to handle exception cases, to declare a block of statements that are essentially bound to be executed
Float One of the basic data types, single-precision floating-point number types
For A guide word for a cyclic structure
Goto Reserved keywords, no specific meaning
If Guide Words for conditional statements
Implements Indicates that 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 a specified type
Int One of the basic data types, integer type
Interface Interface
Long One of the basic data types, long integer type
Native Used to declare a method that is implemented by a computer-related language (such as the C/c++/fortran Language)
New Used to create a new instance object
Package Package
Private An access control method: private mode
Protected An access control method: protection mode
Public An access control method: common mode
Return Returning data from member methods
Short One of the basic data types, the short integer type
Static Indicates a static property
Strictfp Used to declare fp_strict (single-precision or double-precision floating-point number) expressions that follow the IEEE 754 arithmetic specification
Super Indicates a reference to the parent type of the current object or a constructor for the parent type
Switch Guide words for Branching statement structures
Synchronized Indicates that a piece of code needs to be executed synchronously
This Reference to the current instance object
Throw Throws an exception
Throws Declares all exceptions that need to be thrown in the currently defined member method
Transient Declaring a member domain without serialization
Try Try a block that might throw an exception
void Declares that the current member method does not return a value
Volatile
  
Indicates that two or more variables must be changed in a synchronized manner
While
  
Used in the loop structure


5.java Access Control characters
Two types of Access modifiers:
Accessible modifiers: default, public, protected, Private
Inaccessible Modifiers: final, abstract, strictfp
6.java arrays

An array is an ordered set of elements of the same type, and the element type of an array in Java can be either a basic data type or an Object.

The elements in the array can be obtained by array name and subscript, array subscript starting from 0,

An array can be either a one-dimensional array or a multidimensional array.
Declaring a one-dimensional array

int exmaple[] or int[] example

Initializes an array of
Static initialization:
int[] example={1,2,3};
Dynamic initialization
int[] example;
int[] example=new int[3];
example[0]=1;
Declaring a multidimensional array is the same operation, which is not mentioned Here.
7. Enumeration
Restricting a variable by using an enumeration can only be a predetermined value; in Layman's terms, enumerations are understood as constants and constants that you define Yourself.
The use of enumerations is described in more detail in the following article.
Example:
Class Freshjuice {
Enum freshjuicesize{SMALL, meduim, LARGE}
Freshjuicesize size;
}

public class Freshjuicetest {
public static void main (String []args) {
Freshjuice juice = new Freshjuice ();
Juice.size = Freshjuice. freshjuicesize.meduim;
}
}
8. Notes
Java Annotations Support Single-line comments and multiline comments, using annotations on the one hand, you can block out temporarily unused code, and on the other hand use annotations to describe a program or parameter.
Example://comment Content

/**
*javadoc
*
*/

Re-walk Java--step 2

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.