Some basic Java knowledge points that must be mastered

Source: Internet
Author: User


Let's take a look at the basics of Java so that we have a complete grasp of and knowledge of Java's architecture.

First, the basic knowledge

Three technical architectures for 1.Java

Javaee:java Platform Enterprise Edition, the development of applications in the corporate environment, mainly for the development of web programs;

Javase:java Platform Standard Edition, complete the development of desktop applications, is the basis of the other two;

Javame:java Platform Micro Edition, the development of electronic consumer products and embedded devices, such as mobile phone programs;

2.JVM, JRE, and JDK differences

JVM (Java Virtual machine): Java VMS, which are used to ensure the characteristics of Java cross-platform.

The Java language is a cross-platform, and the JVM is not cross-platform.

JRE (Java Runtime Environment): Java Runtime Environment, including Jvm+java's core class library.

JDK (Java Development Kit): Java development tools, including jre+ development tools

3. What is the role of the environment variable path and classpath?

(1) path is the directory in which the program file named. exe is located, specifying the path to the DOS Window command, by configuring the search path for the Windows executable file.
(2) Classpath is the directory where the class file is configured to specify the data class search path that the JVM uses to find the class class file for that category.

Configuration of environment variables:

1): Permanent configuration mode: java_home=% installation path%\JAVA\JDK
Path=%java_home%\bin

2): Temporary configuration mode: Set path=%path%; C:\Program Files\java\jdk\bin

Features: The system defaults to the current path to find the program to execute, if not, then go to the path set in the paths to find.

4. What is the role of variables?
Variable: Used to keep constant of the same type, and can be reused

5. Data type

(1) Basic book type (4 classes 8 kinds):
Integer type: Byte, short, int, long
Float type: float, double
Character type: Char
Boolean type: Boolean (Ture false)

(2) Reference data type :
Class
Interface
Array

6. Memory structure

Stack memory: Used to store local variables, and when the data is used up, the occupied space is automatically freed.
Heap memory: An array and an object that are stored in heap memory by the instance created by new.
Method Area: Static member, constructor, Chang, thread pool
Local Method Area: Window System occupancy
Register: the fastest storage location

7. Arrays

Concept: A collection of the same data types.
Benefit: The elements in the array can be automatically numbered starting with 0, allowing them to be manipulated.

8. Overloading

Concept: In the same class, more than one function with the same name is allowed, as long as the number of arguments or the type of the parameter are different.
Features: independent of return value type, see only parameter list (parameter type and parameter personality)
Advantages: It is convenient to read and optimize the program design.

9.& and && differences

&: Regardless of the left result, the right side is involved in the operation.

&&: Short circuit with, if the left is false, then the right side is not a parameter and operation.

| and | | Difference: |: Both sides are calculated.

|| : Short circuit or, if the left is true, then the right side does not participate in the operation.

Two: Object-oriented:

(1) Overview: Object-oriented is relative to the process, the emphasis is on the function of the process, object-oriented is to encapsulate the function into the object, emphasizing the function of the object.

(2) thought characteristic:

A:是符合人们思考习惯的一种思想。B:将复杂的事情简单化了。C:将程序员从执行者变为指挥者。

For example, if I want to achieve some kind of result, I will look for the object that can help me achieve the function of this result, if I want to wash clothes I will buy washing machine, as for how to wash I don't care.

(3) Characteristics:

Encapsulation: Hide the properties and implementation details of an object and provide public access only externally

Inheritance: When the same properties and behaviors exist in multiple files, they are extracted into a single class, so that multiple classes do not need to define these property behaviors, as long as they inherit that class.

Polymorphism: A variety of States represented by an object at different times of the program, a reference to a parent class or interface, or something like that

Abstraction: Ignores aspects of a topic that are not relevant to the current goal in order to pay more attention to the aspects related to the current goal. Abstractions do not intend to understand all of the problems, but simply select one part of them, temporarily without some detail. Abstract includes two aspects, one is the process abstraction, the other is the data abstraction.

2. Classes and objects

Class: The description of something in the real world is abstract, conceptual.

Object: The individual in which the matter exists.

3. Anonymous objects

(1) An anonymous object is an object without a name. is a shorthand form of an object.

(2) Application Scenarios

A: Call only the methods in the class once.

B: Can be used as a method of actual parameters.


4. Keyword private: The embodiment of encapsulation in code

(1) Private fun, permission modifier

(2) To modify member variables and member functions

(3) Members with private decoration are only valid in this class

(4) Private is a manifestation of encapsulation

5. Building functions

Used to initialize an object, it is to initialize the corresponding object, it is targeted, one of the functions.

Characteristics:
1: The name of the function is the same as the name of the class in which it resides.
2: You do not need to define a return value type.
3: The function does not have a specific return value.
Remember: When all objects are created, they need to be initialized before they can be used.

Note: When a class is defined, if a constructor is not defined, the constructor for an empty argument is automatically generated in the class, and initialization is done to facilitate the class to create the object. If a constructor is customized in a class, then the default constructor is gone.

In a class, you can have multiple constructors, because their function names are the same, so they can only be distinguished by a parameter list. So, if more than one constructor appears in a class. Their existence is manifested by overloading.

6.this keywords

(1) The This keyword represents a reference to the object of this class, who calls the where this is located, and this represents who

(2) The use of this scenario

A: Used to distinguish member variables and local variables of the same name;

B: When defining a function, the function's internal object is called, because the object is not yet established, so this represents the object

C: Build calls between functions

* * This time, this (parameter) must exist as the first statement.


7.static keywords

(1) static meaning, used to modify member variables and member functions

(2) Static characteristics:

        随着类的加载而加载        优于对象存在        对所有对象共享         被可以被类名直接调用 (3)静态的主意事项            A:静态方法只能访问静态成员            为什么?因为静态的内容是随着类的加载而加载,它是先进内存的。            B:静态方法中不能使用this.super关键字            C:主方法是静态的

Some basic Java knowledge points that must be mastered

Related Article

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.