Textbook Knowledge Summary Fourth Chapter class and Object
- Classes: including class declarations and class bodies
- Basic format:
class 类名 { 类体的内容 }
- class declaration: Class+ class Name (note: The first letter of the class name should be capitalized)
- Class Body: A pair of "{" and "}" after a class declaration and their contents, including the definition of a variable's declaration and method
- Method: Including method header and method body
方法头 { 方法体的内容 }
- Construction method and object creation
- Create object: The moniker name of the class
- Object access variables: objects. Variables
- An object invokes a method in a class: an object. method
- Class variable: A declared variable that is given a modification with static
- Instance variable: Declared variable that is not decorated with static
- Instance method: Method type with no static decoration
- Class method: Method type with static modification
- this keyword
- In the instance method
- Pair variable: this. Member variable
- When a static member variable appears in an instance method: Class name. Member Variable
- Invoke instance method: this. method
- Call class Method: Class name. method
- Format: Package Name
- Compile: Javac main class name. java
- Run: Java package name. Main class Name
- Import statement
- Introduce all the classes in a package: import java.util.*;
- Access rights
- Private variables: Member variables that are decorated with private
- Common variables: Member variables modified with public
Study problem record this week
The directory was not found when compiling the program during JDB debugging
WORKAROUND: Compile-time file is a. class suffix file, to jump to his directory folder bin, and bin with the file name is a space, no/
After commissioning and then run
Workaround: Do not add-classpath before Jdb debugging, the class name should not be followed by the. java. Attach Classpath's explanation
When you run a program with a package name on the book
WORKAROUND: There are two different programs in this package, compile Stu.java first, compile Example4_15.java, and then run Example4_15
Occurs when running a triangle class with a package
Program for
Workaround: Create the appropriate folder for the name after the package, move the program into the folder, and run the compilation
- When compiling a program, you can use thejavac-g-D. /.. /bin class name. Java"enables class files to be automatically stored in the bin directory, and then run with"JAVA-CP. /.. /bin class name "
- Shift operator:>>, << for signed shift,>>> for unsigned shift
- & Operations: Two x 1 o'clock is 1, otherwise 0
- | operation: Two x 0 o'clock is 0, otherwise 1
- ^ Operation: 0 at the same time. Otherwise 1
The content in parentheses after the IF statement can only be true or false
Code Hosting
This week's summary
- In this week's study, I found that the amount of code has increased, the amount of knowledge on the textbook has increased a lot, but also need to understand the operation of some basic commands to learn from the heart, not only in the notebook, the teacher also added some new knowledge content, the class really must be well consolidated. In addition to knock the code process to be more careful, some symbols often leak compilation error, to have patience!
20165330 2017-2018-2 "Java Programming" 3rd Week study Summary