Java Basics-Day 2nd

Source: Internet
Author: User

Learning content:

1. Java Language Foundation

Keywords (all letters are lowercase)

class//class

interface//interface

byte//byte bit: bit

short//short-Integer 2 byte

int//Integral type 4 bytes

long//Long integer 8 bytes

float//floating Point type

double//double-precision floating point.

char//characters

boolean//Boolean false True

void//Empty

null//empty, not present

if//if

esel//otherwise

switch//Branch

case//situation.

default//default, default

while//when ... Cycle

do//

For//for Cycle

break//Interrupt

continue//continue

return//return

[Access rights control]

private//Private

proected//protected

public//the public

[Class function Modifier]

abstract//Abstract

final//the final

static//Static

Synchronized//Sync

extends//extension

implements//implementation

new//New

this//Current

SUPER//Super class, parent class,

Whether instanceof//is an instance of XXX

try//try

catch//capture

finally//final

throw//throws

throws//throws an exception when defining a class declaration

package//Bag

import//Import Export

native//the Local

transient//instantaneous, temporary, temporary persistent.

asset//Assertion

Specification of custom identifiers, note that Java is strictly case-sensitive;

Note: single-line comment//, multiline comment/* */, document comment/** */(Javadoc), develop good habit of writing notes;

2, constant, can not be changed,

1, integer constant. All integers

2, decimal constant. All decimals

3, Boolean type constant. More unique, only two values. True false.

4, character constant. A numeric letter or symbol is identified by a single quotation mark (' ').

5, string constant. Identifies one or more characters in double quotation marks ("").

The 6,null constant. There is only one value: null.

3, integer four types of representation

Binary: 0,1, full 2 in 1

Octal: 0-7, full 8 in 1. Start with a 0 representation

Decimal: 0-9, full 10 in 1

Hex: 0-9,a-f, full 16 in 1. Start with a 0x representation

Conversion between the binary, weight,

Negative numbers are expressed in the form of the complement of the original code, and the positive and negative numbers are added 0, overflow the highest bit, exactly equal to 0;

-128 in the memory of the binary is 1000 0000, can be obtained by 127-1;

All the binary if each is 1, then its real data is-1;

Positive numbers also support the complement, which is consistent with the source code;

Positive numbers can be negative minus one negation;

How to get the binary representation of a negative number quickly by a positive number: starting from the lowest bit the same until the first 1 you meet, the back of all the reverse.

4, variable, used to keep the same type of constant, and can be reused

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

5, Java is a strong type, for each data type in memory allocated a different size of memory space

Basic data types

BYTE, short, int (positive default), long, float (decimal default), double, Char, Boolean

Reference data type

class, interface, []

Automatic (implicit) type conversion

Forcing (explicit) type conversions

6, Operator: arithmetic operator, assignment operator, comparison operator, logical operator, bitwise operator, ternary operator

Java is strongly typed, so the result of its operation and real life is somewhat different, in order to preserve the original memory, the underlying will do automatic conversion, discard high, only retain their own number of bits;

Permissions calculation Model: Logical Operations &, | To improve the efficiency of operations, such as the design of LIUNX systems.

Logic Operations &, | Why there is no short circuit: because it is converted to bits operations, bit operations require both sides to participate.

7. Program Flow Control

Judging structure

If Else

Switch

Loop structure

While

Do While

For

8. Functions

Modifier returns a value type function name (parameter type form parameter 1, parameter type parameter 2, ...)

{

Execute the statement;

return value;

}

Functions can only be called, and functions cannot be defined inside a function;

function overloading (number and type of arguments), variable parameters ...


Questions to help:

The permissions calculation model is still not quite clear!!!


Java Basics-Day 2nd

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.