Chapter One overview of the Java language
1. Three attributes of an object: encapsulation, inheritance, and polymorphism.
Encapsulation: Separates the designer and user of the object,
Access level: Public, protected, default, private (General attribute private, method public)
2. Language Features:
1) Object-oriented
2) Cross-platform
3) Support for distributed network applications
4) Safety: Avoid illegal memory operation, etc.
5) Multithreading
3. First Java Program
1) Two types of applicantion and applets
2) Java source file has only one public class with the same name as the source file
3) 3 Types of annotations
4) applicantion Three methods of program entry
5) class block, method block {...}
6) The browser calls the applet's bytecode file as follows:
Import Java.applet.Applet; Import java.awt.*; public class Helloapplet extends applet{ public void Paint (Graphics g) { g.DrawString ("Hello applet!", 30,50); } } |
<HTML> <BODY> <applet Code = helloapplet.class width = height = > </APPLET> </BODY> </HTML> |
Chapter II Data types
1. Identifiers (Letters, underscores, $) and keywords
2. Constants and variables
(Final modifier constant: final double PI = 3.14)
3. Basic data types
1) integral type (Byte,short,int,long 1,2,4,8 bytes respectively)
(1 defaults to int, 1L to cast to long type)
2) floating-point type (float,double 4, 8 bytes respectively)
3) Character type (char, 2 bytes, Unicode encoding, both Chinese and English are represented by one character)
4) Boolean type (, without declaring default to False)
4. Reference data types
1) class type
2) interface type
3) Array type
Chapter Three operator
1. Arithmetic operators
1) integer operator (unary integer operator, two-tuple integer operator)
2) floating-point operator
2. Relational operators
3. Logical operators
4. Bitwise operators (bitwise operators, displacement operators)
5. Assignment operators
6. String operator (string+int or output string type)
7. Special operator (? : 、.、 New 、... )
8. Basic Data type conversions
1) automatic type conversion (Byte, char, short, int, float, double)
The result of the operation between short is also int,int and the float operation get float
2) Forced type conversion
9. Precedence of various operators
Fourth Chapter control statements
1. Branch statements
2. Looping statements
3. Process Jump Statement
Chapter Fifth Class and Object
1. Classes and Packages (package mechanism is for class renaming, Java Virtual machine automatically references packages in Java.lang)
2. Variables
1) member variables and local variables, scope
If the member variable has the same name as the local variable, the member method accesses the member variable and adds this, otherwise
2) Instance member variables and class member variables
(The class has an object that changes the class member variable, and the class member variable of the other object changes accordingly)
int a = 12; Global member variables static int b = 10; Static member variables void F () { int C = 23; Local variables } |
3. Member Methods
1) class member methods and instance member methods
2) parameter passing (simple data type and reference data type)
4. Objects (declaring and allocating memory, garbage collection mechanism finalize ())
5. Overloading of methods (number of parameters or different types)
A small byte type matches a multibyte type when the arguments and formal parameter types are inconsistent
6. Access permission modifiers
Public
Protected: (same package: similar to public; different packages: classes to inherit different packages to use)
Default: The same package can be accessed
Private: Can be accessed in the same class
7. Encapsulation
Chapter sixth succession and polymorphism
1. Inheritance (extends)
1) Same package: Subclasses can inherit the parent class except private member methods and member variables
Different packages: Subclasses can inherit parent classes in addition to private, friendly types of member methods and member variables
2) Variable hiding and method rewriting (override): Overridden method Access must be more lenient than the parent class
3) Super Keyword:
Super calls the construction method of the parent class: (super< parameter list >)
Subclasses cannot inherit the construction method of the parent class;
Super first statement in subclass constructor;
The subclass constructor method does not explicitly call the parent class construction method, and the parent class does not have a parameterless constructor, and the compilation error occurs.
this< parameter list > Calling other constructor methods of this class
Super calls the member variables and methods that are hidden by the parent class:
4) Final modifier
Modified class: The class cannot be inherited and cannot have subclasses
Modification method: Method cannot be overridden
Modifier member Variable: The variable is a constant and cannot be changed
Parameters in the Adornment method: internal cannot change his value
2. Polymorphism (Design-time polymorphism and run-time polymorphism): Increased code reuse rate
3. Design-time polymorphism: overloading of methods
4. Runtime Polymorphism: Object transformation is divided into top and bottom transitions:
On a transformed object (a reference to the parent class is directed to the object of the subclass):
Attributes: inheritance, overriding parent class method, parent class reference to child class object
Ability to access all member variables of the parent class and methods that are not overridden (the parent class).
After the type conversion (into the subclass type), the member variables and methods of the child class are given precedence.
5. instanceof Operator: Right class on left object, return Boolean type
Seventh chapter abstract Classes and Interfaces
1. Abstract modifier
1) Abstract class:
Can contain construction methods
Abstract classes do not necessarily include abstract methods, but abstract methods must be abstract classes
Abstract methods simply declare, without implementing
2) Abstract method
2. Interface
The methods in the interface are all abstract methods, and you can define static final member variables
3. Use of various modifiers
The eighth Chapter Java common Class
1. String class
Length, charAt, equals, substring
2. StringBuffer class
GetChars, Setcharat, append, IndexOf, toString
3. Packing class
String s = ""; INTN = Integer.parseint (s);
Int m = 100; Strings = integer.tostring (m);
Integer in = new Integer (100); int m = In.intvalue ();
4. Math class
SQRT, round, random, Max, MIN, ABS
5. Random class
6. Object class
Nineth chapter Arrays and collections
1. Declaration and creation of arrays
int []a = new INT[10]
2. Initialization of arrays
1) Dynamic initialization
2) Static initialization
3) Default Initialization
3. Common methods of arrays
BinarySearch
CopyOf, Copyofrange
Equals, fill, sort, toString, arraycopy
4. Multidimensional arrays
5. Collection (self-checking the use of related functions http://blog.csdn.net/zhangerqing/article/details/8122075)
1) List interface (Save object Order)
2) set interface (using its own internal sorting method)
3) Map interface (key-value pairs, regardless of order)
Tenth Chapter exception
1. Exceptions are classified as error and exception, and are subclasses of Throwable
The error class object is generated by the Java Virtual machine and is not processed by the program;
Exception class objects are handled or thrown by the application
2. Non-check type exception and check type exception
3. Java uses try, catch, finally to catch exceptions, throw exceptions with throw, throws
4. Java custom exceptions are used to meet special business
5. Common exception Classes
11th Chapter Multithreading
1. Threads in Java
Differences between programs, processes, and threads
Each process has its own memory unit, the thread shares the memory unit
2. Thread creation and startup
1) Create and run threads by inheriting the thread class
Java does not support multiple inheritance, so the class cannot be a subclass of another class
2) Implement runnable to create threads
3. State Transitions for threads
New, operational, operational, blocked and dead
4. Thread Life cycle
5. Scheduling of threads
1) Thread Priority: 1~10 low-to-high
Min_priority, Norm_priority, max_priority
SetPriority (n), getpriority ()
2) Thread sleep:
Thread.Sleep () allows low-priority threads to run first
3) Threading Concessions
4) Thread.yield () Let the same priority thread run
5) Wait for other threads to end
Thread.Join ()
6. Thread Synchronization
1) Add synchronized to the front of the method and lock
2) Wait is the method of the object class, and sleep is the method of the thread class
3) Wait when other threads can access the locked object, call the wait method to lock the object, and no other thread can lock the object while sleep
12th Input/output system (http://www.cnblogs.com/dolphin0520/p/3791327.html)
1. Overview
1) Data Flow
2) input stream and output stream
3) Buffered stream
2. Files and directories
1) file class (file name or path)
2) basic operation of directories and files
To create a file object, get files or directory properties, file or directory operations
3. Byte stream
FileInputStream, Bytearrayinputstream, DataInputStream
FileOutputStream, Bytearrayoutputstream, DataOutputStream
4. Character Stream
FileReader, Bufferreader
FileWriter, Bufferwriter
5. Standard I/O
System.in, System.out, System.err
6. Serialization and deserialization of objects
Object serialization: Converting objects into binary streams (implementing serializable, externalizable interfaces)
Object deserialization:
Confidential information does not want to be serialized: 1) encryption before declaring the attribute with transient;2)
7. I/O exception
13th Chapter Graphical user interface (GUI)
1. AWT window components (abstractwindowing Toolkit)
1) consumes more resources than swing
2) java.awt packages and components
Compenent class
Color class
Font class
Label class
Button class
CheckBox class
TextComponent class
3) container (Container)
1) window: Frame Class (frame), dialog box class (Dialog)
2) faceplate (panel)
2. Use of layout Manager
AWT five layout managers, inherited from Java.lang.Object
1) FlowLayout
2) BorderLayout
3) GridLayout
4) CardLayout
5) GridBagLayout
3. Application of event handling
1) event handling mechanism
Delegating event Model (dem,delegation)
Event: A state change, such as a user clicking a button, and so on.
Event Source: The component that can generate events
Event Listener: An event source must register listeners in order to listen for specific event types.
Step: (1) Register the event listener to the event source, (2) Implement the event handling method.
2) AWT event class and listener interface
3) How the event is handled
(1) Using listener interface to implement event processing
(2) Implement event handling with adapter classes
(3) Implement event handling using internal classes
(4) using anonymous inner classes to implement event handling
4. Swing components and their applications
It has more features than AWT, which is not controlled by the hardware platform.
1) border
Titledborder class, Etchedborder class
2) button
JButton
3) text Box
JTextField
4) Text area and scrolling panel
JTextArea, JScrollPane
5) check box and radio button
Jcheckbox, Jradionbutton
6) combo box and list box
JComboBox, JList
7) Page Check panel
JTabbedPane
8) Form
JTable
9) Menu
Menu Bar JMenuBar
Menu JMenu
menu item JMenuItem
Check menu item JCheckBoxMenuItem
Single-Selection menu item JRadioButtonMenuItem
To add a shortcut key to a menu item: JMenuItem item1 = new JMenuItem ("Open", ' O ');
To add an accelerator to a menu item (select a menu without opening it, note the difference from the shortcut key)
Pop-up menu JPopupMenu
10) dialog box (jdialog) and message box (Joptionpane)
14th Chapter Java Applet
15th. JDBC and database operations
1. Common Database
Bd2,oracle,sqlserver,mysql
2. mysql Database
Enter database: Mysql–u root–p
Creating database: Create Database name
Delete database: Drop database if exists DB name
Working with databases: use database names
Creating tables: Create TABLE tablename (field Name field type [default defaults] [constraint]);
Delete tables: DROP TABLE TableName
View database: Show databases
View tables in the database: Show tables from dbname
View the structure of the table: DESC tablename; Showcolumns from Dbname.tablename
Insert data: INSERT INTO tablename[(COLUMN1,COLUMN2)] VALUES (value1,value2);
Delete data: Delete from tablename [where conditions]
Updated data: Update tablename Set column1 = value [, Column2 = value2] wherecondition;
Query data: SELECT {* | column alias} from table name [query condition]
1) Fuzzy query: SELECT * from user where username%
2) Limit command:
Start querying n rows from the m+1 line: SELECT * from user limit m,n;
Export Data: SELECT * FROM tablename [where conditions] to outfile filename;
SELECT * from account into outfile ' e:/tutorial content/java/java2.txt ';
Import data: Load infile filename into table tablename
Load datainfile ' e:/tutorial content/java/java2.txt ' into table lesson.account;
Export sql:
Export database: Mysqldump–u root–p databasename > E:\book_system.sql
Export table: Mysqldump–u root–p dadtabasename tablename > E:/user.sql
Import sql:
Mysql–u root–p databasename <e:/book_system.sql
Or: Sourcee:/hrbfareast.sql
3. SQL Graphical interface operation
MYSQL Workbench, PhpMyAdmin, SQLyog, Toad formysql
4. JDBC (Javadatabase Connectivity)
1) Concept:
An API that accesses a variety of different types of databases in the same way.
Two interfaces: For the Java Application developer interface, the driver interface for the personnel interface.
Java Application Developer: (Establish a database connection, commit an SQL statement, process the returned result set)
2) JDBC Driver type:
JDBC-ODBC Drive
JDBC Local driver
JDBC Network Driver
Pure Java driver for local protocol
3) connection, increase and deletion check operation
Package Com.sysu.jerry; Import java.beans.Statement; Import java.sql.*; public class Main9 { public static final String dbdriver = "Com.mysql.jdbc.Driver"; public static final String dburl_string = "Jdbc:mysql://localhost:3306/lesson"; public static final String DBUSER = "root"; public static final String Dbpass = "13345156"; public static void Main (string[] args) { TODO auto-generated Method Stub int n=0; Connection conn = null; Statement stmtstatement = null; String sqlString = "INSERT into account (Username,password) VALUES (5, ' e ')"; try { Class.forName (Dbdriver); conn = Drivermanager.getconnection (dburl_string, DBUSER, Dbpass); Stmtstatement = Conn.createstatement (); n = stmtstatement.executeupdate (sqlString); System.out.println ("Add" +n+ "record"); Stmtstatement.close (); Conn.close (); }catch (ClassNotFoundException E1) { TODO auto-generated Catch block E1.printstacktrace (); } catch (SQLException e) { TODO auto-generated Catch block E.printstacktrace (); } } } |
4) transactions (a series of basic operations are inseparable)
5) connection pool and data source
Basic knowledge of Java programming