Summary of the contents of textbook Learning seventh chapter
- Inner class
- Anonymous class
- Exception class
- Assertion
Tenth Chapter Essentials
- File class
- File byte/character input, output stream
- Buffered streams
- Random stream
- Array flow
- Data flow
- Object Flow
- Serialization and object cloning
- Parsing files using scanner
- File lock
Problems in teaching materials learning and the solution process I. Internal class
Java key members : member variables, methods, inner classes
Inner class : Defines another class in one class, the defined class is called an inner class
outer-Nested class: An outer class that contains the inner class of the class called Inner classes
- important relationships between the inner class and the outer-nested class :
- The member variables of the outer-nested class are still valid in the inner class, and methods within the inner class can also call methods in the outer-nested class
- The class body in an inner class cannot declare class variables and class methods. The class body of an outer-nested class can declare an object with an inner class
- The inner class is used only for its outer-nested classes
The inner class corresponds to the bytecode file name format :外嵌类名$内部类名
Inner classes can be decorated as static inner classes, but non-intrinsic classes cannot be static classes
Second, anonymous class
- Anonymous classes related to subclasses
- Anonymous classes: Subclasses remove the class body after class declaration
Form:
new Bank() {匿名类的类体};
- Characteristics:
- Anonymous classes are subcategories
- Anonymous classes can also inherit methods from the parent class or override the parent class's methods
- An anonymous class must be an inner class that creates an object directly in a class with an anonymous class
- Anonymous classes can access member variables and methods in outer-nested classes, and cannot declare static member variables and static methods in the class body of an anonymous class
- When you create an object with an anonymous class, you use the constructor of the parent class directly
- Anonymous classes related to interfaces
Third, the Exception class
Iv. assertions
Syntax format for assertion statements
assert booleanExpression;assert booleanExpression:messageException;
Enable and close assertion statements
java -ea mainClass
V. File class
Vi. input/output stream
- use the input stream step :
- Set the source of the input stream
- To create an input stream to a source
- Let the input stream read the data in the stream
- Close the input stream
- To use the output stream step :
- Give the destination of the output stream
- Create an output stream to a destination
- Let the output stream write data to the destination
- Turn off the output stream
- file byte input stream :
- Construction method:
FileInputStream(String name); ,FileInputStream(File file);
- To read bytes using the input stream:
read
- To close a stream:
close()
- file byte output stream :
- Construction Method:
FileInputStream (String name); , fileinputstream (file file); The
- reads bytes using the input stream:
| write Method |
|
| void write (int n) |
output stream call this method to write data to the destination |
| void Write (byte b[]) |
output stream call this method to write to the destination a byte array |
| void Write (byte b[],int off,int len) |
In a given byte array starting at offset off, take Len bytes to write to destination |
| void Close () |
close output stream |
- file character input stream, file character input stream :
Vii. Other flows
- Random Flow:
RandomAccessFile
- byte array stream:
ByteArrayInputStream ,ByteArrayoutputStream
- Character array flow:
CharArrayReader ,CharArrayWrite
- Data flow:
DataInputStream ,DataoutputStream
- Object flow:
ObjectInputStream ,ObjectoutputStream
Problems in code debugging and the resolution process
After installing idea last week, I used idea to write code, and I had to say that the completion function of idea has made it easy to use, with a key run to run automatically, and debug debugging is clearer and easier. The seventh chapter of the code does not appear any problem, the understanding is not very complex, but the tenth chapter code is mostly in the gun, there are a lot of problems, the following a little bit to solve.
A problem occurred running:
Problem found:
Solve the problem:
A problem occurred running:
Solve the problem:
(method i) Copy the Java file to the previous level folder to read out
(Method Two) the "." In the source code Change to "src/."
Problem found:
Solve the problem:
- Summary : Idea in the path is very important!! Do not set up may cause many errors, such as not reading the file and other issues
Code Hosting
See blog: https://gitee.com/BESTI-IS-JAVA-2018/20165223cn.git
Learning progress Bar
|
lines of code (new/cumulative) |
Blog Volume (Add/accumulate) |
Learning Time (new/cumulative) |
Important Growth |
| Goal |
3000 rows |
30 Articles |
400 hours |
|
| Week Five |
1324/200 |
3/11 |
20/20 |
Gradually deepen |
Resources
- Instructional Videos
- Debugging Java programs with JDB
20165223 Java programming Fifth week of study summary