Java review Summary 1
Java System Review
Basic Core java SE
Based on java SE, java EE is mainly used for the development of large-scale enterprise-level applications.
It is also divided into another java ME, mainly used for embedded development.
JVM (Java Virtual Machine) Java Virtual Machine
Cross-platform java is implemented by JVM.
JDK: Java Development Kit (Java Development Kit)
JRE: Java Runtime Envir (Java Runtime Environment)
Build a java Development Environment
Step 1 install JDK
Step 2 configure Environment Variables
Step 3: verify whether the environment configuration is successful
Use Notepad
Command: javac HelloWorld. java to generate a. class File
Run: java HelloWorld
Java program development process using IDE
1. Create a java Project
2. Create a package
3. Compile a java source program
4. Run the java program
Program porting
Print, println, the former output does not wrap, the latter output line feed
Breakpoint debugging
F6 one-step execution
Object-oriented
Object Concept
What Is Object-Oriented
Class
Object Attributes
Object Method
Relationship/difference between classes and objects
Object Concept: Objects exist objectively,
Class: A class is a model that determines the features (attributes) and behaviors (methods) that an object will possess)
Class features: a class is a set of objects with the same attributes and methods.
Object Attributes: various features of an object. Each attribute of an object has a specific value.
Method: operations performed by the object
Relationships between classes and objects: classes are abstract concepts. They are just templates, and objects are yours.
Specific entities that can be viewed and touched
Definition class
Importance of classes: All java programs use class classes as organizational units
What is a class: A class is a model that determines the features (attributes) and behaviors (methods) that an object will possess)
Class composition: attributes and Methods
Steps for defining a class
1. Define the class name
2. Write the attributes of the class
3. Method of writing classes
Steps for using objects:
1. Create an object
Class Name object name = new Class Name ();
2. Objects used
Member variables and local variables
Member variables
Defines in the class to describe what the object will have. member variables can be used in methods of this class and other classes.
Local variable
Defines in the method of the class, saves data temporarily in the method, and can only be used in the current method
Differences between member variables and local variables
Different scopes
The scope of a local variable is limited to defining its methods.
The scope of member variables is visible within the class.
Different initial values
Java will give the member variable an initial value.
Java does not assign an initial value to a local variable.
Local variables with the same name are not allowed in the same method.
In different methods, local variables with the same name can exist.
When the two variables have the same name, the local variables have a higher priority.
Constructor
1. Use the new + constructor to create a new object.
2. the constructor is a method defined in the java class to initialize objects.
The constructor has the same name as the class and has no returned value.
If no constructor is specified, the system automatically adds a constructor without parameters.
If a constructor has a specified constructor, no constructor with or without parameters will automatically add a constructor without parameters.
Overload of constructor: multiple methods with the same method name but different parameters are automatically selected based on different parameters during calling.
The constructor not only assigns values to attributes of an object, but also ensures that a reasonable value is assigned to attributes of an object.