1: Basic Concept

Source: Internet
Author: User

Brief introduction


DOS command

Commands can be used in the DOS direct input javadoc, JAVAC, etc.

-D <directory> destination directory for output files

Code Format :

    1. Braces align to the line with the left curly brace and the closing brace
    2. Indent when opening curly braces: Tab or shift+tab, do not use spaces to indent, indent one square.
    3. Empty lines in a block, such as between a method and a method, between variables and methods
    4. Add a space in a side-by statement
    5. Operation plus a space, such as int i = 1;



Package

    • Import Packa. Demoa; Import the Demoa class in the Packa package.
    • Import Packa. DEMOAA;
    • Import Packa. DEMOAAA;


    • Import packa.*;//Imports all the classes in the Packa package: * represents all
    • Import packa.abc.*;
    • Packa\demoa.class
    • Packa\abc\demoabc.class


The principle of the Guide package: which class to import, and which class to use.

What does import do with it? To simplify the writing of the class name.

Jar:java the compressed package.

The classes in the package are accessed, the classes in the package being accessed must be public, and the methods of the classes in the package being accessed must also be public.

Identifier

1.Java the sequence of characters used when naming features such as variables, methods, and classes is called identifiers

All the places where you can name them are called identifiers.

2. Define the rules for legal identifiers:

Made up of 26 English letters, Numbers: 0-9, _ or $

Numbers may not start.

You cannot use keywords and reserved words, but you can include keywords and reserved words.

Java is strictly case-sensitive and has unlimited length.

Identifiers cannot contain spaces.

Note: In the name of the, in order to improve the reading, as far as possible to make sense, "see the name know."


Naming conventions for names in Java

Package Name: All letters are lowercase when multiple words are composed: xxx.yyy.zzz

Class name Interface name: When multiple words are composed, the first letter of all words is capitalized: xxxyyyzzz

Variable name and function name: When multiple words are composed, the first letter is lowercase, the second word starts with the first letter of each word capitalized: xxxyyyzzz

Constant name: All letters are capitalized. Multiple words each word with an underscore connection: xxx_yyy_zzz

Constant


Variable

1. Concept of a variable: A storage area in memory that has its own name (variable name) and type (data type)

Each variable in 2.Java must be declared before it is assigned a value. A statement is a name.

Data in this region can vary from one type to the same range

Define the format of the variable: data type variable name = Initialize value

variable is used to access this area by using the variable name.

Use variables Note:

Scope of the variable: valid between a pair of {}

Classification of variables

1. By declared location: (see object-oriented beginner for details)

Member variables: Variables that are internally defined by methods outside of the class

Local variables: Variables defined inside a method or statement block, see parentheses

Note: Outside the class (outside the braces for the class) cannot have the declaration of the variable

2. Divide by the data type that belongs to:

Basic Data type variables

Reference data type variables

  

Commonly used escape characters

\ n: Enter:

\ t: tab.

\b: Backspace.

\ r: Press ENTER.

The carriage return character in Windows system is actually a two-symbol \ r \ n.


operator

Attention:

1. logical operators are used to concatenate Boolean expressions, which cannot be written as 3<x<6 in Java and should be written in X>3 && x<6.

2.Thedifference between "&" and "&&":

Single &, both True and false on the left, the right side of the operation;

Double & If the left is true, the right side participates in the operation, if the left is false, then the right side does not participate in the operation.

and "| |" The difference is the same, dual or time, the left is true, the right does not participate in the operation.

3. xor (^) and OR (|) The difference is: for ^, when both left and right are true, the result is false.

Ternary operators

Format:

(conditional expression)? Expression 1: Expression 2;

If the condition is true, the result of the operation is an expression of 1;

If the condition is false, the result of the operation is an expression of 2;

The ternary operator is the IF Else statement shorthand format.

  
 
  1. int a = 3,b;
  2. /*
  3. if(a>1)
  4. b = 100;
  5. else
  6. b = 200;
  7. */
  8. b = a>1?100:200;

When does the shorthand format work?

When the ifelse operation has a specific result, it can be simplified as a ternary operator.






From for notes (Wiz)

1: Basic Concept

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.