Java Learning Notes (i)

Source: Internet
Author: User

First, Java overview

1. Compiled and interpreted languages

The 2.JAVA is first compiled into a platform-independent bytecode (*.class) file, which is then interpreted by the JVM (Java Virtual machine) and eventually converted to a computer code.

3. The JVM on different platforms is different, but provides the same interface for cross-platform purposes.

4.jre:java Runtime Environment

Jdk:java Development Kit

Sdk:software Development Kit

II. basic data types and operators

1. Floating-point type default is double, to declare float type needs to be followed by F or F, for example 3.4F

Float a = 3.4//error! float a = (float) 5.6 can be cast

2. Positive Infinity: positive_infinity negative Infinity: negative_infinity non-number: NaN returns infinity only if the float is divided by 0, and integer/0 throws an exception

3. When an arithmetic expression contains more than one type of value, an automatic promotion occurs, and a byte short char is promoted to int

4. & Bitwise AND

| Bitwise OR

~ Bitwise non-

^ Bitwise XOR: Same return 0, different return 1

<<: Left Shift 0

>>: Right shift sign bit

>>>: Right Shift 0

5. Number in the computer to complement the existence of a positive complement is its own, negative complement the first sign bit (0 positive 1 negative), the rest of the inverse code +1 (0000B represents -128d)

6. Shift char short char to int re-shift

7.& always calculates the right side of the,&& only if the left is true

Third, the face of the object

Call Relationship between 1.valueOf (),toString ()

   Public Static String valueOf (Object obj) {  returnnull)? "Null": obj.tostring (); }

2. Static members: Members that have static adornments belong to the class itself, can not instantiate the call, and members with no static adornments belong to instances of the class

In a 3.static decorated method, this cannot point to the appropriate object (because the method belongs to the class itself), so non-static members cannot be accessed directly

The 4.JAVA parameter is passed as a value pass, and you want to pass a reference to create a class

5. Encapsulation: The state information of the object is hidden inside, and the external program is not allowed to access the internal information of the object directly, but to implement the internal information operation and access through the method provided by the class:

1) Hide the implementation details of the class

2) can only be accessed through a predetermined method, restricting unreasonable access

3) data Check to ensure the integrity of object information

4) Easy to modify, improve maintenance

6.JAVA only a single inheritance, only a direct parent class, can have an infinite indirect parent class, using the Extend keyword

7. Rewrite override, two small one: the same method name, the same parameter list, return value type, throw exception is smaller than the parent class, access permissions than the parent class

Overloaded overload occur between multiple identically named methods of the same class, and overrides occur between the same name methods of the parent and child classes

8.super qualifying invocation of an instance method of the parent class being overridden

Class base{  public  int a = 5;  } Class sub{public   int a = 7;   public int access () {    return super.a;}}

9. polymorphic: There are two types of reference variables for Java, compile-time type and run-time type, how they are different, will appear polymorphic

Condition: 1. To have inheritance

2. To have a rewrite

3. Parent class reference to Child class object (BaseClass T = new Subclass ();//t at compile time is subclass base, runtime is parent sub)

10. The initialization block is also a class member and is always executed before the constructor executes; static initialization blocks (class initialization blocks) execute at the class initialization stage, rather than creating the object, so he executes the first one than the normal initialization block.

11. = = and Equals method

When comparing reference-type variables, only they point to the same object, = = Returns True, and Equals () has an override in string, compares the reference, returns false and compares the characters, returns true equal, or returns false, as described in:/HTTP Www.cnblogs.com/xudong-bupt/p/3960177.html

12.final Retouching

13. Abstract classes are modified with abstract, can not be instantiated, can only be inherited, with the method of abstract modification in subclasses must be rewritten

14.static and abstract cannot modify a method at the same time, but you can modify an inner class at the same time

15. The interface defines a specification that uses the interface keyword, cannot contain constructors and initialization blocks, can contain only static member constants, methods (abstract instance methods, class methods, default methods), inner classes.

Interface all members By default use public adornment, member variable default public static final decoration, normal method default public static decoration, it cannot have method implementation, default method (Defalt) The Adornment and class methods (static adornments) must have a method implementation.

 Public Interfaceoutput{//member variables defined in an interface can only be constants    intMax_cache_line = 50; //The normal method defined in the interface can only be an abstract method of public    voidout (); voidGetData (String msg); //define default method in interface, need to use default adornment    default voidprint (String ... msgs) { for(String msg:msgs) {System.out.println (msg); }    }    //define default method in interface, need to use default adornment    default voidTest () {System.out.println ("Default test () method"); }    //defining a class method in an interface requires the use of the static modifier    StaticString statictest () {return"Class method in the interface"; }}

16. The interface fully supports multiple inheritance and cannot be used to create instances, but can declare reference variables and then refer to objects that implement classes, for example:

Interface a{} class Implements  New B (); // Declare a B instance xx with interface a

17. The interface embodies a specification, and abstract class embodies a template-style design

18. Inner class: Http://www.cnblogs.com/nerxious/archive/2013/01/24/2875649.html

...

Not to be continued

Java Learning Notes (i)

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.