Java Basic applications

Source: Internet
Author: User

symbols for bitwise operators:

& ( with ): Both are 1 When I am one, the others are 0

| ( or ) : Both are 0 only when the 0 , the others are 1.

^ ( xor ): The difference between the two is 1, the same as 0

~ ( inverse ):0 becomes 1,1 becomes 0.

the representation of negative numbers: The highest bit of bits is 1, so this number is a negative.

rule: Negative number corresponding to the positive number-1 , the inverse negative number corresponding to the positive number reversed +1

Role: Data is encrypted

shift Operators :

>> Right Shift

rule: shift the number of digits to the right by dividing by 2 How many times you want to move

<< left Shift

rule: how many digits to the left, multiply the number by 2 times.

>>> unsigned Right shift

function : increases the operation rate. Bit arithmetic is the fastest execution.

features : A number A and two the same number ^, the final result is still the original number a.

Looping Statements

While loop: First judge the execution

Structure:

while ( loop condition ) {

Loop body.

}

do and loop: once executed, the loop body is bound to execute once .

structure :

bo=

circulation body ;

}while ( cyclic conditions );

For Loop:

Structure:

for (;;) {

Loop body

}

Java Object-oriented programming:

The three main characteristics of object-oriented: encapsulation, inheritance, polymorphism. Class, Object.

Object: The only thing that really exists.

Object-oriented programming (OOP) idea: is to make the description of things in computer language and the things in nature as consistent as possible.

Object-oriented Core: Find the right object to do the right thing.

How to find the right object in Java:


1.sun classes are already assigned, and you need to know these classes to create objects from custom-made classes.


2. Customize the class to create the object from the custom class.


The class contains: properties, methods.

The definition format of the class:

Class name {

Attribute (member variable): Describes the public characteristics of a thing.


Method: Describe the behavior of a thing (what to do)
}

Create an object from a custom class


Format:
Class Name Object name (variable name) = new class name ();

Creating objects from the car class
Car car = new car ();

Setting properties
Car.color = "Red";
Car.name = "BMW";

Call Method:
Car.run ();



Java Basic applications

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.