Java is an object-oriented programming language. It not only absorbs various advantages of C++ language, but also abandons concepts such as multiple inheritance and pointers that are difficult to understand in C++. Therefore, Java language is powerful and easy to use. This article mainly introduces the summary of java basic knowledge, specifically follow Xiaobian together to find out.
One, java overviewIn 1991, Sun's James Gosling and others began to develop the language called Oak, which is intended to control microprocessors embedded in cable exchange boxes, PDAs, etc.
Renamed the Oak language to Java in 1994;
Java's three technical architectures:
JAVAEE: Java Platform Enterprise Edition, the development of enterprise environment applications, mainly for web application development;
JAVASE: Java Platform Standard Edition, the completion of the development of desktop applications, is the basis of the other two;
JAVAME: Java Platform Micro Edition, developing electronic consumer products and embedded devices, such as programs in mobile phones;
1, JDK: Java Development Kit, java development and operating environment, java development tools and jre.
2, JRE: Java Runtime Environment, running environment of java program, java required class library + JVM (java virtual machine).
3, configure the environment variables: let java jdk \ bin directory tool, you can run in any directory, the reason is that the directory where the tool is told to the system, when using the tool, the system helps us to find the specified directory .
Configuration of environment variables:
1): Permanent configuration: 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 default to the current path to find the program to be executed, if not, then go to the path set in the path to find.
The classpath configuration:
1): Permanent configuration method: classpath=. ;c:\;e:\
2): Temporary configuration mode: set classpath=. ;c:\;e:\
Note: When you define the classpath environment variable, you need to pay attention to the situation
If you do not define the environment variable classpath, java will start the jvm, will find the class file to be run in the current directory;
If classpath is specified, the class file to be run is found in the specified directory.
Will you find it in the current directory? Two situations:
1): If there is a semicolon at the end of the value of the classpath, the running class is not found in the specific path, it will find it again in the current directory by default.
2): If the value of the classpath does not have a semicolon, the running class is not found in the specific path and will not be found in the current directory.
Generally do not specify the semicolon, if you do not find the class file to be run under the specified directory, an error is reported so that the program can be debugged.
4. What do the javac command and the java command do?
To know that java is divided into two parts: one is compiled, one is running.
Javac: Responsible for the compilation part, when javac is executed, it will start the java compiler program. Compile the .java file with the specified extension. Generated a bytecode file that jvm can recognize. That is, the class file, which is the running program of java.
Java: The part responsible for running. Will start jvm. Load the library needed by the runtime and execute the class file.
For a file to be executed, there must be a starting point for the execution. The starting point is the main function.
Second, the basics of java syntax1, Keywords: In fact, a language is given a special meaning of the word.
Reserved word: It is actually a word that has not been given a special meaning but is ready for use in the future.
2, identifier: In fact, is a custom noun in the program. For example, class name, variable name, function name. Contains 0-9, az, $, _;
note:
1) The number cannot begin with.
2) You can't use keywords.
3, constants: data that will not change in the program.
4, variable: Actually it is a storage space in memory, used for storing constant data.
Role: easy to calculate. Because some data is uncertain. So determine the nouns and storage space for the data.
Features: Variable space can be reused.
When is the variable defined? As long as data is uncertain, variables are defined.
What are the elements needed to open up the variable space?
1. What data does this space need to store? type of data.
What is the name of this space? The variable name.
3. What is the first data of this space? The initialization value of the variable.
Scope and lifetime of variables:
The scope of the variable:
The scope begins at the position defined by the variable, and ends with the curly braces to which the variable belongs.
Life cycle:
Variables live in memory from the defined position;
The variable disappears in memory when it reaches the scope it is in;
type of data:
1): Basic data types: byte, short, int, long, float, double, char, boolean
2): Reference data types: arrays, classes, interfaces.
Level from low to high: byte, char, short (the three levels) - "int--" float--" long--" double
Automatic type conversion: from low level to high level, the system automatically transfers;
Mandatory type conversion: When to use? Assign a high-level number to a low-level variable that does not have that number;
calculating signs:
1), arithmetic operators.
+ - * / % %: Any integer modulo 2 is either 0 or 1, so as long as the modulo is changed, the switching operation can be performed.
+: connector.
++,--
2), assignment operator.
= += -= *= /= %=
3) Comparison operators.
Features: The characteristics of this operator are: The result of the operation is either true or false.
4) Logical operators.
& | ^! && ||
Logical operators except! Both are used to connect two boolean type expressions.
&: true if both sides are true. Otherwise it is false.
|: As long as both sides are false the result is false, otherwise it is true
^: Exclusive or: It's not the same as or different.
The same as both results, it is false.
The result is not the same on both sides, it is true.
& & && difference: & : Regardless of the left result, the right side participates in the operation.
&&: short-circuit and, if the left is false, then the right is not an argument and operation.
Difference between | and ||: |: Both operations.
||: Short-circuit or if the left side is true, then the right side does not participate in the operation.
5) Bit operators: Operators for manipulating binary bits.
5, statement.
If switch do while while for
When are these statements used?
1) When determining the value of a fixed number, you can use if or switch.
However, it is recommended to use a switch with relatively high efficiency.
Switch (variable) {
Case value: the statement to be executed; break;
...
Default: the statement to be executed;
}
How it works: Use the value of the variable in parentheses and the value after the case in order to compare with which case is the same value
The statement following the case is executed, if there is no identical statement executed after the default;
Details: 1):break can be omitted, if omitted, it is executed until it encounters a break;
2): The variables in the parentheses following the switch should be one of four types: byte, char, short, and int;
3) :default can be written anywhere in the switch structure; if the default statement is placed on the first line, the program will start execution from default until the first break occurs, regardless of whether the value in expression matches the value in the case.
2) When determining the data range and obtaining the boolean type of the evaluation operation result, use if.
3) When a certain statement needs to be executed many times, it uses a loop structure.
While and for can be interchanged.
The difference is that if you need to define a variable to control the number of loops. It is recommended to use for. Because the for loop is finished, the variable is released in memory.
Break: Acts on switch , and looping statements for jumping out, or ending.
When the break statement exists alone, no other statement is defined below, because the execution fails and the compilation fails. When the loop is nested, break only jumps out of the current loop. To jump out of the outer loop in the nest, just name the loop. This name is called a label.
Continue: only acts on the loop structure and continues to loop.
Role: End this cycle and continue with the next cycle. When the statement exists alone, the following statements cannot be defined and cannot be executed.
6, function: In order to improve the reusability of the code, you can define it as a separate function, the function of which is the function in java. The function is one of the manifestations.
The definition of the function in java format:
Modifier return value type function name (parameter type formal parameter 1, argument type formal argument 1, ...) {
Execute statement
Return return value;
}
When the function does not have a specific return value, the returned return value type is represented by the void keyword.
If the function's return type is void, the return statement can be omitted and the system will automatically add it for you.
The role of return: end function. End function.
How to define a function?
A function is actually a function. Defining a function is a function. It is done through two things:
1), clear the result of the operation of the function, in fact, is clear the return value type of this function.
2) Whether or not unknown content participates in the operation during the implementation of this function is actually to specify the parameter list of this function (parameter type & number of parameters).
The role of the function:
1), used to define the function.
2) Used to encapsulate code to improve code reusability.
Note: Only functions can be called in functions, and functions cannot be defined.
Main function:
1) Guarantee the independent operation of this class.
2) Because it is the entrance to the program.
3) because it is called by jvm.
What is the function definition name?
Answer: 1) In order to mark the function, it is convenient to call.
2) In order to increase the readability of the code, the function of the function can be clearly defined by the name.
The overload definition is: In a class, if there are two or more functions with the same name, as long as the number of their parameters, or the type of the parameter is different, it can be called the overloaded function.
How to distinguish between overloads: When the function has the same name, just look at the parameter list. It does not matter with the return value type.
7, array: a container for storing the same type of data. Benefits: The data in this container can be numbered starting from zero. Arrays are used to encapsulate data and are a concrete entity.
How to represent an array in java? Two forms of expression.
1) Element type [] variable name = new element type [number of elements];
2) Element type [] variable name = {element 1, element 2. . };
Element type [] variable name = new element type [] {element 1, element 2. . };
// Dichotomous search. There must be a prerequisite: the elements in the array must be ordered.
Public static int halfSeach_2(int[] arr,int key){
Int min,max,mid;
Min = 0;
Max = arr.length-1;
Mid = (max+min)""1; //(max+min)/2;
While(arr[mid]!=key){
If(key)arr[mid]){
Min = mid + 1;
}
Else if(key "arr[mid])
Max = mid - 1;
If (max "min")
Return -1;
Mid = (max+min)""1;
}
Return mid;
}
1
Java is divided into 5 pieces of memory.
1: register. 2: Local method area. 3: Method area. 4: stack. 5: Heap.
Stack: Stores all local variables (variables defined in functions, parameters on functions, and variables in statements);
As soon as the area where the data operation is completed ends, the data is released.
Heap: Used to store arrays and objects, ie entities. What is the entity? It is used to package multiple data.
1: Each entity has a memory first address value.
2: Variables in heap memory have default initialization values. Because of the different data types, the values ​​are not the same.
3: Garbage collection mechanism.
15.6 inch i5 5th Budget Gaming Laptop in plastic is more competitive one in device in 2022, only need around 300usd. However, 15.6 inch 500 dollar gaming laptops is one of the most important top 10 budget gaming laptops, like 14 inch i7 budget gaming laptop under 500, 15.6 inch 11th 512gb laptop, etc.
However, top budget gaming laptops also have other levels, like 15.6 inch i5 laptop 10th generation, 15.6 inch 11th generation laptop i7 512gb, etc. 2022 top laptops under 500 with 14 inch i3 i5 i7 10th you can see here also.
The custom laptop is also of updated, quality hardware, big battery, rich slots, charging by Type C, etc.
Nowadays, the hardware and mature of custom laptop is nearly no difference with brand one, so pls believe you can get a satisfy laptop for your special project, like students project, office project, gaming club etc.
Except laptop, also have custom Android Tablet, Mini PC , All In One PC, 2 In 1 Laptop, also availble.
Any other specail demand, you can contact us and share your requirements details, then matched details sended quickly.
Budget Gaming Laptop,Budget Gaming Laptop Under 500,Top Budget Gaming Laptops,Top Laptops Under 500,Top 10 Budget Gaming Laptops
Henan Shuyi Electronics Co., Ltd. , https://www.shuyiminipc.com