Java Runtime Environment

Source: Internet
Author: User

1.Java Development Environment:
1) Java compilation run process:-----------Common face questions
1.1) Compile period:. Java source files, compiled, generate. Class bytecode files
1.2) Runtime: JVM loads. Class and runs. Class (0 and 1)
Features: cross-platform, one-time programming used everywhere

2) noun Explanation:
2.1) Jvm:java Virtual machine
Load the. Class and run the. class
2.2) Jre:java Operating environment
In addition to containing the JVM, it also contains the necessary environment for running Java programs
Jre=jvm+java System Class Library
2.3) Jdk:java Development Kit
The command tools necessary to develop Java programs are included in addition to the JRE.
Jdk=jre+ compile, run, and other command tools
Description
1) The minimum environment for running Java programs is JRE
2) The minimum environment for developing Java programs is JDK

3) Configure Environment variables:
3.1) Java_home: The installation directory that points to the JDK
3.2) CLASSPATH: Represents the search path for a class, as a general shorthand.
3.3) PATH: Point to the bin directory under JDK

2.eclipse:
1) IBM, open source, free, do not need to install only need to decompress
2) Steps:
2.1) New Java Project/engineering----------------
2.2) New Java package--------------------
2.3) New Java class--------------
3) Notes: Explanatory text
3.1) Single-line comment://
3.2) Multi-line Comment:/* */
3.3) Documentation Note:/** */

Variable: The number of the stored, pronoun, and the number of its stored
1) Statement:
int A; Declare a variable of integer type named a
int b,c,d; Declares a variable of three integers named B,c,d
2) Initialization: First time assignment
2.1) Declare simultaneous initialization
int a = 100;
2.2) first declaration after initialization
int A;
A = 100;
3) Use:
3.1) The use of the variable is the use of the number it has stored
int a = 5; Declares an integer variable A and assigns a value of 5
int b = a+10; Remove the value of a of 5, plus 10, and then assign to the integer variable b
System.out.println (b); Value of output variable b 15
System.out.println ("B"); Output B, as-is output in double quotes
A = a+10; Remove the value of a of 5, plus 10, and then assign a value to a
Increase by 10 on the basis of a itself
System.out.println (a); The value of the output variable a 15
3.2) The operation of the variable must match the data type
int a = 3.14; Compilation error, data type mismatch
3.3) variables must be declared and initialized before they are used
System.out.println (m); Compilation error, m not declared
int m;
System.out.println (m); Compilation error, m not initialized
4) Name:
4.1) can contain only letters, numbers, _, and $, and cannot start with a number
4.2) strictly case-sensitive
4.3) cannot use keywords
4.4) can be named in Chinese, but not recommended
Suggestion: "The name of the English language", "Hump name Law"
2. Basic data type:
1) int: integer, 4 byte,-21 million to 21 multi billion
1.1) Integer Direct quantity defaults to int type, but not over range, compiler error in hyper range
1.2) divide two integers, the result is an integer, the decimal place is unconditionally discarded
1.3) Overflow occurs when the operation is out of range, and overflow is required to avoid
2) Long: Length, 8 bytes, very large very large
2.1) The direct amount of the long integer, the number must be added L or l
2.2) If the arithmetic operation is likely to overflow, it is recommended that the 1th number plus L
2.3) System.currenttimemillis () to be obtained from
1970.1.1 0 o'clock the number of milliseconds to this moment
3) Double: floating-point, 8-byte, very large, very large
3.1) floating-point Direct is the default type double, which indicates that float must be followed by a number F or f
3.2) Rounding error may occur when floating-point data participates in the operation
4) Boolean: Boolean, 1-byte
4.1) only true and false can be installed
5) Char: Character type, 2 bytes
5.1) Use Unicode character set encoding, each character has a corresponding code
The representation is char, but essentially a code int (between 0 and 65535)
(ASCII code: ' A '--97 ' a '--65 ' 0 '--48)
5.2) The direct amount of characters must be enclosed in single quotes, with only one
5.3) Special symbols need to be escaped by \
3. Conversions between basic data types:
Data types from small to large are:
Byte,short,int,long,float,double
Char
1) Two types of methods:
1.1) Automatic type conversion: Small type to large type
1.2) Coercion type conversion: Large type to small type
(The data type to be converted) variable
Strong turns are likely to overflow or loss of precision
2) Two-point rule:
2.1) Integer direct value can be directly assigned to Byte,short,char,
But not out of range.
2.2) When the Byte,short,char data participates in the operation,
Convert to int before operation
Usage of 4.Scanner:
1) under the package:
Import Java.util.Scanner;
2) in the main () method:
Scanner scan = new Scanner (system.in);
3) below the 2nd step:
System.out.println ("Please enter Age:");
int age = Scan.nextint ();
System.out.println ("Please enter the price:");
Double price = Scan.nextdouble ();

Operator:
1) arithmetic operator: +-*/%,++,--
2) relational operator: >,<,>=,<=,==,!= Boolean
3) logical operator: &&,| |,! Boolean
4) Assignment operator: =,+=,-=,*=,/=,%=
5) String Join operator: +
6) Condition/three-mesh operator: Boolean number 1: Number 2
2. Branching structure: Conditional execution of a statement
1) If:1 Road
2) If...else:2 Road


Notes:
1. Branching structure:
1) If structure: 1 paths
2) If...else structure: 2 roads
3) IF...ELSE If structure: multiple paths
4) Switch...case structure: Multiple paths
Advantages: High efficiency, clear structure
Cons: Integers, equals
Break: Jump out of switch
2. Cycle:
1) repeated execution of the same or similar code
2) cyclic three elements:
2.1) Initialization of cyclic variables
2.2) Conditions of the loop (based on the cyclic variable)
2.3) changes in cyclic variables (toward the end of the cycle)
Loop variable: The number of repeated changes over the course of the cycle
3) Cycle structure:
3.1) While: After the judgment is executed, it is possible not to execute at once
3.2) Do...while: Execute first and then judge, at least once
Feature 1 is the same as feature 3, preferred Do...while

Loop structure:
1) While:
2) Do...while:
3) for: fixed number of cycles
2.break: Jump out of the loop
Continue: Skips the remaining statements in the loop body and goes to the next loop
3. Better application of three cycle structures:
1) while: "When ..."
2) Do...while: "Until ..."
Feature 1 is the same as feature 3, preferred Do...while
3) for: fixed times, highest application rate
4. Nested loops:
1) loop in the loop, generally multi-row multi-column when used, the outer control row, the Inner control column
2) Execution rules: Outer loop Walk once, inner layer cycle all times
3) Recommendation: The less cycle level, the better, can use a layer without two layers, can use two layers without three layers
If your needs have to go through the three-layer cycle to solve the problem of design
4) Break can only jump out of a layer of loops
6. program = algorithm + data structure
1) algorithm: process/step for problem Solving (order, branch, Loop)
2) Data structure: to save it in a specific structure
Designing a reasonable/good data structure can lead to good algorithms
7. Arrays:
1) Collection of elements of the same data type
2) An array is a data type (reference type)
3) Definition of the array:
int[] arr = new INT[10];
4) Initialization of the array:
int[] arr = new INT[3]; 0,0,0
Int[] arr = {2,5,8}; 2,5,8
int[] arr = new int[]{2,5,8}; 2,5,8
Int[] arr;
arr = {2,5,8}; Compile error
arr = new int[]{2,5,8}; That's right
5) Array of access:
5.1) You can get the length of the array by (array name. length)
int[] arr = new INT[3];
System.out.println (arr.length); 3
5.2) access to elements in the array by subscript/index
Subscript starting from 0, Max to (length of array-1)
int[] arr = new INT[3];
ARR[0] = 100; Assigns a value of 100 to the 1th element in arr
ARR[1] = 200; Assigns a value of 200 to the 2nd element in arr
ARR[2] = 300; Assigns a value of 300 to the 3rd element in arr
ARR[3] = 400; Array subscript out of bounds exception
System.out.println (Arr[arr.length-1]); Output the value of the last element in arr
6) Array Traversal:
int[] arr = new INT[10];
for (int i=0;i<arr.length;i++) {
Arr[i] = 100;
}
for (int i=0;i<arr.length;i++) {
System.out.println (Arr[i]);
}
for (int i=arr.length-1;i>=0;i--) {
System.out.println (Arr[i]);
}

Array:
7) Copying of arrays:
7.1) system.arraycopy (a,1,a1,0,4); Good flexibility and high efficiency
7.2) int[] A1 = arrays.copyof (a,6); Poor flexibility and low efficiency
A = arrays.copyof (a,a.length+1); Special purpose (expansion of arrays)
8) sort the array:
8.1) Arrays.sort (arr); Ascending order
8.2) Bubble sort:---------------common face questions
8.2.1) Five count four rounds
8.2.2) Each round starts with a 1th element
Every time, it's more than the next element.
8.2.3) Don't take it out of the game.
2. Methods: Functions, procedures
1) for encapsulating a specific business logic function
2) be as independent as possible, one way or the other.
3) method can be called repeatedly
4) Reduce code duplication, facilitate code maintenance, and facilitate team collaboration
3. Definition of the method:
Modifier return value type method name (parameter list) {
Method body
}
4. Invocation of the method:
1) No return value: Method name (with reference to the parameter);
2) There is a return value: Data type variable = method name (with reference to the parameter);
Usage of 5.return:
1) return value; 1.1) End method execution 1.2) Returns the result to the caller
-------------------written in the method with the return value
2) return; 2.1) End the execution of the method
-------------------written in a method with no return value

Java Runtime Environment

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.