Java Learning Path (i) Java basics

Source: Internet
Author: User
Tags logical operators

Identifiers (Naming conventions)

  Identifiers are composed of letters, numbers, underscores, ¥, $, and Chinese;

The first letter cannot use numbers;

Cannot duplicate the system keyword;

Length Unlimited, case-sensitive;

Class Name: capitalize each initial letter;

Package name: all lowercase;

Method Name: First word lowercase, other first letter capitalized;

Variable: lowercase;

Constant: Uppercase;

Basic data types

Integer

byte byte type

Short Quick-integer

int integer

Long integer type

Basic data types
Floating point number

Double Dual Precision Type

Float Single precision Type

BYTE type Char 0-65535
Boolean type Boolean (True, False)
Array Reference data type
Class, interface

Variable

Definition and Assignment: Data type variable name = value; Example: int b = 123;

In the process of the operation, the capacity of the small size of the conversion capacity of large, large capacity of small conversion capacity;

1         int a = 3; 2         int b = 6; 3         byte c = (byte) (A+B);

Boolean logical operators

a b ! A ! b a&b

a | b

a&&b a | | b

a^b

true true false false true true true true false
true false false true false true false true true
false true true false false true false true true
False False True True False False False False False

Logical NON (! ): Not true or false. It's not fake.

XOR (^): Same as false. The difference is true;

or (|): As long as one is true;

With (&): As long as there is a false is the false;

Three mesh operator: judgment statement? "For true execution", "for false execution";

Array

1         /**2 * Define static arrays3 * data type [] Variable name = {value};4          */5         int[] A = {};6         intB[] = {-};7         /**8 * Define dynamic arrays9 * data type [] Variable name = new data type "array maximum length";Ten          */ One         int[] C =New int[5]; A         /** - * Define two-dimensional arrays -          */ the         int[] D = {{1,2,3},{4,5,6}}; -         int[] e =New int[2] [2];

Method and Construction method

    /**      * Method Definition     * [modifier]  return value type     method name (parameter  ) {     *         method Body     *}     * parameter definition: Data type  variable name     * return value type: void (no return value), base data type     * Method invocation: Method name ();      */     Public void name () {        }    /**     * Constructor Method     * Modifier    class name () {     *      *}     * method call:     *         class name Variable name = new class name ();      */

Object

Invocation of the object: type variable name = new Type ();

Type generally refers to the class file name;

Modifier

Public Have access to
Private Privatization. This kind of Chinese Academy of Sciences visit
Default The default modifier, which can be accessed within the same package
Protected This class, subclass, and package can be accessed

Inheritance: extends (keywords)

Cast: instanceceof (keyword)

Final: The final modification cannot be changed, cannot be inherited, cannot be rewritten;

Abstract class:

Modified with abstract;

cannot be instantiated directly;

Abstract method is used to modify the method.

Abstract classes are generally used as parent classes of other classes, but must be rewritten;

Cannot have the main method;

Abstract methods are only declared, not implemented;

  

Java Learning Path (i) Java basics

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.