Android Basic Notes

Source: Internet
Author: User

Java Basics
Object-oriented three features
Encapsulating inherited polymorphism

Polymorphic
Define objects that allow different classes to respond to the same message
Technology dynamic binding during execution the actual type of the referenced object is judged based on the actual type called the corresponding method
Coupling relationship between action-eliminating types
Conditional inheritance Overrides parent class reference to child class object
Benefits extended Replacement Interface Flexible simplification

interface meaning
Specification Extension Callback

Abstract class meaning
Provide a common type for other subclasses
Encapsulate duplicate defined content in subclasses
Define abstract method subclasses have different implementations but the definitions are consistent

Abstract class Interface Differences
The default method abstract class can have a default method implemented in the interface without
Implementation method Abstract class extends interface implements
Constructors can have interfaces in an abstract class without
and normal class difference interface non-instantiation interface is different type
Access modifier Interface Default public other cannot
Multiple inheritance a subclass can have more than one interface

Override and Overload differences
Override rewrite subclasses redefine the same method as the parent class
Overload overloads define a new method with the same name as the defined method, but with a different signature

Whether the static method of the parent class can be overridden by a quilt class
Cannot be called hidden

Inner class action

Switch can use string to make arguments
only byte short char int and corresponding wrapper class Enum are supported before JAVA7
JAVA7 supports string

Nine basic types of data
Boolean Boolean
BYTE 1 byte
Short 2 short
int 4 Integer
Long 8 long
Float 4 Float
Double 8 Double
Char 2 Character
void void

Java Collection
Collection
Abstractlist
Vector
ArrayList
Abstractsequentiallist
LinkedList
Map
Abstractmap
HashMap
TreeMap
Dictionary
Hashtable
Abstractset
HashSet
TreeSet
Vector
Array-based implementations
Many ways to join synchronized synchronization statements to ensure thread safety
Allow element to be null
Now basically don't use

ArrayList
Array-based implementations
Non-threading security can only be used in single-threaded environments
Allow element to be null
Find high efficiency Insert Delete need to move a large number of elements inefficient

LinkedList
The two-terminal queue of the chain-stack queue based on the bidirectional cyclic link list
Non-threading security can only be used in single-threaded environments
Allow element to be null
Insert Delete Efficiency high find low efficiency

HashMap
A hash table-based implementation of each element is a key-value internally resolved conflict through a single-linked list
Non-thread safe
Key-value are allowed to be empty

TreeMap
Special binary sorting tree based on red-black tree
Key cannot be null
Query Insert Delete is not hashmap high efficiency generally need to sort key to use

Hashtable
1.0 Introduction based on hash table implementation
Thread Safety
Key-value are not allowed to be empty

HashSet
Through the HashMap in map
TreeSet
Through the TreeMap in map

Jvm
Four types of references
Strong reference to new memory space is not sufficient JVM does not recycle
Soft reference memory is out of space the JVM recycles
Weak reference JVM will be recycled whenever it finds out whether the current memory space is sufficient
A virtual reference to the object it points to is reclaimed when it is added to the reference queue so that it points to when the object is destroyed

Partition
Thread sharing
Java heap holds all object instances and arrays
The method area holds the class information that has been loaded by the virtual machine constant static variable The immediate compiler compiled code
Thread Private
The line number indicator of the byte code executed by the current thread of the program counter
Memory model for virtual machine stack Java method execution
Each method is executed to create a stack frame
stack frame for storing local variable table operand stack dynamic Link method return address some additional additional information
The local method stack is similar to the virtual machine stack as a native method service

Partitioning examples
Object obj = new Object ()
obj is saved as a reference type in the virtual machine stack
The referenced instantiation object is saved in the Java heap
Address information for the object type data is saved in the method area

Memory leaks
The allocated memory is not recycled, and the loss of control over the area of memory caused a waste of resources.
Memory overflow
The memory required by the program exceeds the maximum amount of memory the system can allocate

Method of judging garbage collection
Reference count
Object has reference counter plus 1 references invalid minus 1 to 0 object not to be used
Problems with object Circular referencing are difficult to solve

Reference chain
Starting point through a series of GC roots objects
The path to search down from these nodes is called the reference chain
When an object is connected to a GC roots without any reference chain, it proves that the object is not available

Garbage collection algorithm
Mark Clear Method
Mark all objects that need to be recycled after the tag is complete, unified recycling
Low mark and recycle efficiency creates a lot of memory fragmentation

Replication Algorithms
Divide the memory into two pieces equal in size and use only one piece at a time when a piece is exhausted
Copy the surviving object to another one that has been used to clean up once

Marker finishing for the old age
Mark all objects that need to be recycled to move all surviving objects to one end
And then clean out the memory outside of the boundary directly.

Android Basic Notes

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.