Implementing object-Oriented Programming with Java (12)

Source: Internet
Author: User
Tags set set try catch

Here is a summary of the previous:

1-4:
Packaging:
1. Abstract classes in the real world:
A. Discovery of an object----category
B. Looking for its properties from an object---"Property
C. Finding its behavior from an object---"Method


2.new
In the Java language, when you want to invoke a method in a class or property needs to instantiate this object


3. Constructors
A.public modifier method Name and class name do not return
B. The system provides an argument-free construction by default
c. If you manually (forcibly) write a construction method, the system-supplied parameterless constructs will disappear
D. Actions to perform property initialization in a class
E.new Construction Method ()


4.static
A. Function in Attribute method static{} (static block)
B. When static block content is executed: Call static method or static property when creating an object
C. class name. static property class name. static method
D. Initialization operation to complete a static property


5.this
A. Property methods in this class can only be called in this class to construct
B.this. Method () this. property
C. Call the constructor method in this class this () this (args)
D.this () only allows writing to the constructor method and only appears in the first row


6. Package:
Properties in the privatization class expose a Get set method that accesses the property (narrowly encapsulated)

Inherited:
1. Keyword extends
2. What can be inherited:
Static F
Private modifier F
Construction Method F
Final-Modified F

3. Access rights
Public this class T sub-class T different package t
Protected T Class T Sub-group of different buns T
The default class T is the same package (whether or not) subclass T
Private This class T

4.super
A. Calling the property method construction of the parent class in this class
B.super. Method () Super. Properties
C.super () constructor method that calls the parent class in the constructor of a subclass has and can only appear in the first row

. There is an inheritance relationship between father and son;
Public Father () {
Print ("Father")
}


Public Son () {
Print ("Son")

}

Son s = new Son ();

Father son

**5+1

static{
Print ("Father Static")
}
Public Father () {
Print ("Father")
}

static{
Print ("Son static")
}
Public Son () {
Print ("Son")

}

Son s = new Son ();


Static block of parent class--"subclass static fast from top to bottom execution
Construction of the parent class--sub-class construction

Object-oriented 3 concepts

Polymorphic
A. Upward transformation
Parent Class F = new subclass ();
F.eat (); Sub-class
F.play (); XXX//Cannot call the subclass's unique method

B. Downward transformation
Parent Class F = new subclass ();
Sub-Class Z = (subclass) F;
Z.eat ()//Sub-class
Z.play (); Can call

Instanceof: Determines whether this variable is an object type (reference data type)

String str = "123";
if (str instanceof String) {
Print ("string")
}else if (str instanceof int) {
Print ("int")
}

Interface
A.interface definition
B. All methods in the interface are abstract methods
C. All variables in the interface are static constants must be given to the initial value
D. Construction method in interface (F)
There are construction methods in the abstract class (T)
E. Interface as a set of template technology method replacement implementation

Abnormal
1. English exception
**2.
5 Common types of anomalies
NullPointerException
Indexoutofboundsexception
ClassCastException Type Conversion exception
ClassNotFoundException class exception not found
Inputmismatchexception the input mismatch exception


3.try Catch finally throw throws
Try: A block of code that may appear to allow the exception to be used alone (not allowed) with catch or finally at least one federated use
Catch: The appropriate processing for a specific exception can write multiple (yes)
Finally: The code is bound to be executed regardless of whether an exception occurs
Throw: Throws an instance of an exception in the method body
Throws: Declaring an exception type on the method header

4. Run-time Exception checked exception
A. Run-time exceptions do not require the user to force try catch processing
B.checked exception must be handled by exception

5.exception Error Difference
A. The former is a program that can be processed to make the program work properly
B.error program cannot solve by handling code

Collection
80%
A. List set is an interface (T)
List set Inherits Collection interface (T)
Map Inheritance Collection Interface (F)

**b.collection: Not a unique unordered object
List: not unique order
Set: Only unordered


C.list List = new ArrayList ();
A. Based on the object array implementation
B. Deposit object Add ()
C. Length size ()
D. Get element get (Index) index starting from 0

LinkedList list = new LinkedList ();
A. Based on linked list implementation
B.add () AddFirst addlast
C Size ()
D. Manipulating the Kinsoku elements in a collection


The efficiency of the former traversal is high while the latter increases and deletes the elements efficiently


D.set Set = new HashSet ();
Add () Element
Get () does not have this method
Iterator can be iterated to get


E.map Map = new HashMap ()
Access a set of objects that exist as key-value pairs
Key: Keys unique can be null
Value: Values

Get (key)--->value


**f.arraylist Vector Differences
1. The former thread is unsafe the latter is safe
2. The former by default grows 50% the latter 1 time times
3. The former heavy efficiency

HashMap Hashtable Difference
1. The former thread is unsafe the latter is safe
2.HashMap key value can be null
HashTable key value cannot be null


G.iterator
Next () Hasnext ()


H. Generics
1. Restrictions on the types of objects stored in the collection

Jdbc
1. Load driver build connection write SQL Execute SQL get result close resource
2.class.forname ("SQLServerDriver")
Connection conn = drivermanager.getconnection
String sql = "";
Statement stmt = Conn.createstatement ()
Stmt.executeupdate (SQL)///delete/change executeQuery (SQL)//query


3.PreparedStatement Statement Difference
1. The former generally requires the presence of placeholders (? )
2. The former requires the data to be populated with the pstmt.setxxx () the table below starts from 1
3. Methods used to execute SQL do not allow parameters
4. High efficiency of the former


Data Access Layer
DAO Layer: Entity Class DAO Interface Implementation Tool Class (**********basedao)

Layering concepts
1. Next layer for the previous layer of service the next layer cannot call the previous layer method

/ o
1. Flow direction
Input: Read
Output: Write

Kinds to divide
Byte stream buffer flow binary stream

Files () file

Okay, it's over, then. Use jquery to quickly and efficiently create web interactive effects

Welcome attention, comments, thank you!!!

Implementing object-Oriented Programming with Java (12)

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.