Java (a)--javaBASIC ProgrammingJavaLanguage Introduction (UnderstandingJAVA)
- JVM (Java virtual machine): The JVM is an imaginary computer that can run Java code, which guarantees that Java can be run across platforms, that is, portability, and in line with Sun's slogan: Write Once, run Anywhere. (Write once, run everywhere)
Run as follows: (because the picture cannot be loaded, so do not upload it temporarily)
- Java the architecture of the technology consists of three areas :
EE (Java 2 Platform Enterprise Edition) is a solution for developing applications in an enterprise environment;
J2SE (Java 2 Platform stand Edition) Standard Edition, a solution for desktop development and low-end business applications
J2ME (Java 2 Platform Micro Edition) Small edition, is the best solution for consumer products and embedded devices
- 3. installation of JDK and configuration of environment variables
- Java Salient features : Java program is very special, it must be compiled before the use of the interpretation of the way to run
- Byte-codes The biggest advantage is that it can be run on the platform, making it possible to "write once and run everywhere"
- 6. use classpath to specify the run path of class
For example Hello if in the D disk, now on the C drive to open cmd, you can use the following means to change the open pointing path:
: (Because the picture cannot be loaded, so do not upload it temporarily)
simple.Javaprogram
Will any of the System.out in the Java program Wrap? The println is made up of print and line, so a newline operation is performed after the command is completed.
class, the class name must have the same name as the file name, as long as the class is declared as a public type
Summary:
1. There are three ways to annotate the Java language:
(1), the "//" sign begins, to the end of the line;
(2), "/*" and "* *" between the two symbols of the text;
(3), documentation comments.
2. If a class is declared as public, its file name must be taken to the name of the class in order to compile successfully.
3, Main () is a very special method in Java, it must be declared as public, so that it can be called elsewhere in the class, and the main () method has no return value, so before it to add the void keyword.
4, System.out refers to the standard output, the subsequent connection of the println is composed of print and line, meaning that the contents of the following brackets printed on the standard output device-the display.
5. Because Java programs are composed of classes, there must be at least one class in the complete Java program.
6. The variable name of Java can consist of an English letter, a number, an underscore (_), and a dollar sign ($), but the identifier cannot begin with a number, nor is it a reserved keyword in java. In addition, Java variables are case-sensitive.
7, the variable is set up in the following three ways: at the time of Declaration, set, declare, and declare and set in any place in the program.
8. Methods to improve the readability of the program are:
(1) Add annotations to the program;
(2) Take a meaningful name for the variable;
(3) Keep each line with only one statement;
(4) Proper indentation.
JavaBasic Program Design
Data type:: (because the picture cannot be loaded, so do not upload it temporarily)
Maximum and minimum values for the data type:
Java provides a long, int,short, and byte four integer type of maximum value, the minimum value of the code.
: (Because the picture cannot be loaded, so do not upload it temporarily)
Automatic type conversion:
The conditions that automatic type conversions should meet:
- The data type before conversion is compatible with the converted type, (the Boolean type cannot be converted directly from other types because it has only true and false two cases)
- The converted data type has a larger representation range than the type before conversion
• Summary of Highlights:
1, Java data types can be divided into the following two kinds: basic data type and reference data type.
2, Java provides long, int, short, and byte four integer types of large-value, small-value code. The code for the large value is Max_value, and the small value is min_value. If you are using a large or small value of a type, simply precede the code with the full name of the class to which they belong.
3, Unicode, it has a unique value for each character, so in any language, platform, program can be used with ease.
4, Boolean (Boolean) type of variable, only true (true) and False (false) two values.
5, the conversion of data types can be divided into the following two kinds: "Automatic type conversion" and "forced type conversion".
6, the expression is composed of operands and operators.
7, a unary operator requires only one operand. such as "+3", "~a", "-a" and "!a" are composed of a unary operator and an operand.
8. The members of arithmetic operators are: addition operator, subtraction operator, multiplication operator, division operator, remainder operator.
9. If statement can decide the procedure according to the result of judgment.
10, increment and decrement operators have considerable convenience, use them to improve the simplicity of the program, its members refer to table 4-5.
11. Parentheses () are the Java operators that are used to handle the precedence of an expression.
12, when there is a type mismatch in the expression, there are the following processing methods:
(1) data types that consume less bytes are converted to data types that consume more bytes.
(2) with the short and int types, the int type.
(3) The character type is converted to the short type.
(4) The int type is converted to float type.
(5) If the type of one operand is double, the other operands are also converted to a double type.
(6) A Boolean type cannot be converted to another type.
13, the structure of the program comprises: (1) sequential structure, (2) selection structure, (3) loop structure.
14, the need to repeat a function, the cycle is a good choice. Depending on the needs and habits of the program, you can choose to use the for, while, and do...while loops provided by Java.
15. The break statement allows the forced program to escape the loop. When the program runs to the break statement, it leaves the loop, resumes execution of the next statement outside the loop, and if the break statement appears in the inner loop of the nested loop, the break statement only escapes the current layer loop.
16. The Continue statement can force the program to jump to the beginning of the loop, and when the program runs to the continue statement,
The remaining loop body is stopped and continues to run at the beginning of the loop.
17, the choice structure includes if, if-else and switch statements, the sentence with the choice of structure, like a crossroads, according to different choices, the program will have different directions and results.
18, in the loop can also declare a variable, but the declared variable is only a local variable, as long as the jump out of the loop, this variable can no longer be used.
• Summary of Highlights:
1. An array is a data type consisting of a set of variables of the same type, represented by a common name. The array is divided into one-dimensional, two-dimensional and multidimensional arrays according to the complexity of the storage elements.
2, using the array in Java, you must go through two steps: (1) declare an array, (2) open up memory to the array. 3, in Java to get the length of the array (that is, the number of array elements), you can use. length to complete. 4. If you want to assign an initial value to an array at the time of declaration, simply append the initial value to the declared format of the array. 5. Java allows the number of elements in each row in a two-dimensional array to be different.
6, in a two-dimensional array, if you want to get the entire array of rows, or the number of elements of a row, you can also take advantage of. length to get.
7. Overloading of methods: allow more than one method of the same name to exist in the same class, as long as their arguments
The number or type can be different. In this case, the method is called overloaded, and the process is called a method
Overloads of the.
The first part: Java BASIC programming