Beginners learn basic Java knowledge problem _ finishing

  1. java core strengths:
    a cross-platform, since a different jvm system allows javaapp jvm faced by different operating systems
  2. java versions meanings:
    javaSE: JAVA STANDARD Edition: Standard Edition: positioning a personal computer, core java platform provides a rich API includes AWT and Swing, in addition Applet is FLASH, HTML5 replace; will learn
    javaEE: JAVA ENTERPRISE EDITION: Enterprise version, location server, SE extension, increase class libraries for server development. As the JDBC, the Servlet, the Request-the Response, the JSP
    JAVEME: JAVE On the MICRO: Micro Edition, positioning consumer electronics, J2SE containing part of the core classes, extending within the SE. Android is replaced
  3. Features and Benefits of java:
    ① cross-platform / Portability: If int is always 32
    ② Security: Building a network anti-virus / distributed environment, tamper-proof system
    ③ object-oriented: more than C ++ (compatible C) more thoroughly , fully object-oriented.
    ④ Simplicity: C + ±, removing header, pointer arithmetic, structure, union, operator overloading, virtual base class, based on C easy to learn
    ⑤ high performance: low initial performance, post-optimization jvm added to the JIT (time compilation techniques), by the compiler localized "hot spots" code and cached, improving coding efficiency.
    ⑥ Distributed: designed for distributed environments Internet, to handle TCP / IP protocol, can be accessed through a URL similar to network resources and access to local files, support for remote method invocation (RMI, Remote Method Invocation), so that the program can call through the network method.
    ⑦ Multithreading: bring better interactive and real-time behavior. Also become one of the main reasons for service-side development language.
    ⑧ robustness: the removal of pointers, memory allocation and release. It comes with GC; outstanding exception mechanism to avoid computer crashes and crashes.
  4. java operating mechanism:
    source file .java, by jdk compiler into .class files, bytecode verifier, interpreter and JIT be interpreted, app is running through the system class loader JRE
  5. JVM, JRE, JDK difference
    JVM: java virtual machine: the virtual machine bytecode execution virtual machine bytecode defined: the instruction set, set of registers, a stack structure, the garbage collection heap memory area. Responsible for java byte code interpreter runs, interprets side run.
    JRE: java runtime environment: with JVM, libraries, run java program must file (just run javaapp only need jre)
    the JDK: java Development Kit: contains JRE, as well as increased compilers and debuggers and other documents for program development ( development required);
    the JDK (javac, JAR, the debugging, Tools, javap) "the JRE (the Java, javaw, the Libraries, RT, JAR)" the JVM (the JIT)
  6. Concept identifiers and rules, specifications:
    Concept: for naming: variable, class, method name
    rules: letters, numbers, underscore _, open head by word mother number word under Draw line At the beginning of letters, numbers, underscores, numbers
    case sensitive, no length limit
    may not be as keywords;
    specifications: Class Name: capitalize the first letter of each word
    method names, variables: the first letter of the first word lowercase, and the remaining capitalized word "hump principle"
  7. Essence variables:
    is operable contiguous space, the spatial position is determined, the content of variable, the variable name can be accessed by a "storage space", and operates.
    Comprising: variable name, variable type, scope; length after the first declaration is assigned a respective memory space, [Initialize] used;
  8. Variable types:
    basic types, reference types
  9. Variable Categories:
    Local variables local variable: declared within a block of statements deactivation process dependent method or statement block period following the method of live statement block must be initialized using;
    member variable member variable (instance variables): declare external to the class internal method, series the object, the object follows the cycle, may default initialization,
    static variables static variable (class variables): statement on inner classes, static modification, the slave class, periodic follow class loading, unloading, disappear, can be changed, all share one class object.
  10. Constant definitions, classification:
    Definition: a fixed value (symbolic constant) with a final modification, can not be changed once initialized, (static variable access can not be changed, and therefore became final with a plus static and require constant manual initialization)
    Category: literal: 1,2, true, 'b', "hello"
    symbolic constant: The final modification is defined. final double PI = 3.14;
  11. Variables and constants naming convention:
    all variables, methods, classes name: See name known Italian
    class member variables: the first letter lowercase, hump principle of
    local variables: the first letter lowercase hump principle
    constant: capital letters and underlined combination: MAX_VALUE
    class name: the first letter capital and hump principles: GoodMan
    method name: the first letter lowercase and principles hump
  12. Data type classification, Detailed
    basic data types (primitive data type):
    Numeric:
    integer types: byte 1byte, short 2byte, int 4byte, long 8byte
    floating point type: float 4byte, double 8byte
    character: char 2byte
    Boolean: boolean 1bit
    reference data types (reference data type) :( target address is recorded)
    class: class 4byte
    interfaces: interface 4byte
    array: array [] 4byte
  13. Integer variable range of each type, forms:
    byte 1byte -128-127 (binary eight, plus or minus half sub)
    Short 2byte -32768-32767
    int 4byte -21 -21 one hundred million one hundred million
    Long 8byte -2 63-2 63- 1
  14. Four kinds decimal integer constant expressions:
    Decimal: 99,
    octal: beginning 0
    0X or beginning 0x: hex
    binary: 0b or 0B beginning
  15. Java default integer (literally) Constant Type:
    int, long type literal if statement can be added after the L or l (int without exceeding the range may result, no error is in the range of automatic transition)
  16. And the range of floating-point variables for each type of
    float 4byte -3.4E38-3.4E38
    Double 8byte -3.4E308-3.4E308
    float seven mantissa precisely, is a single common double, double precision float, and
  17. The default type of floating-point literal:
    Double
  18. Each form of the binary floating-literal:
    Decimal: 3.14
    scientific notation: 314e2,314E-2
    after the literal value to increase the float F or F, the default is not a double, or D can be added after the double d
  19. No exact figures calculated using error classes:
    java.math.BigDecimal class for floating-point operations, commonly used in the field of finance.
    java.math.BigInteger type commonly used in integer arithmetic.
  20. Floating-point comparison ways:
    by BigDecimal;
  21. BigDecimal common methods:
    BigDecimal.valueOf (Double): used to obtain an accurate value of the floating point
    subtract (BigDecimal): for subtraction.
    multiply (BigDecimal): multiply
    add (BigDecimal): adder
    divide (BigDecimal): division
    abs (BigDecimal): absolute value
    compareTo (BigDecimal): comparison, other is 0, 1 greatly, a small -1
    Here Insert Picture Description
  22. 'A' == results of "A", why?
    The results are not comparable, the compiler error; one is a character string.
  23. char character set used, the size of the space, the range of
    Unicode character code table, 2 bytes, characters allowed 0-65536; encoding from '\ u000' to '\ uFFFF'
    U represents Unicode, after adding four 16 ary. Note that 'One' is wrong, he is an invalid character
  24. char literal manifestation of
    char can hexadecimal characters can be directly used to represent.
  25. The char commonly escape character \ with
    \ b backspace \ u0008
    \ n-wrap \ u000A
    \ R & lt carriage return \ u000D
    \ T tab Tab \ u0009
    \ "double quote \ u0022
    \ 'single quote \ u0027
    \ backslash \ u005c
  26. The nature of the String:
    sequence of characters: char sequence
  27. boolean constant value true / false occupy space in memory?
    1 person
  28. Operator classification: 8 kinds of
    arithmetic operators (mono-, di-)
    assignment operator
    extension operators
    relational operators (except size, etc., as well as the same for Comparative Example instanceof)
    Logical Operators
    Bitwise
    conditional operator
    character the concatenation operator
  29. Role%:
    modulo, take the remainder
  30. Binary operator operation rule:
    integer arithmetic:
    two integer literal operand, the presence of a Long, Long result is also
    no Long, are int, whether the operand is a byte or short
    floating-point operations:
    There double the result is double
    both to float the result is a float.
    Modulo arithmetic:
    number of floating point operations may, in general an integer, the result is a "remainder", the same reference numerals and the left operand.
  31. Unary operation rule: "+ / -" increment operator
    I ++: first with increment
    ++ I: After the increment with
    the operator to see a first increment, the first increment to the front.
  32. Operand Type relational operators, the result type
    = not relational operators;
    ! ==, all = (basic and reference) data types can be used; when a reference (e.g., String) ratio is a reference to the address.
    '>,> =, <, <=' Only for numeric type (byte / short / int / long , float / double, char)
  33. Operand Type logical operator, the type of the operation result, and & &&, | and || the difference, the exclusive OR ^ is determined by:
    operands and results types: boolean value.
    && is short-circuited and, once left the first condition is false directly returns false, & Analyzing all the operands are required, in addition & operand is non-bit operation when the boolean.
    Returns true || is directly short-circuited and, once left the first condition is true, | it judges whether all operands required, in addition | boolean operands is non-bit operation when the non-
    shorting prevention commonly null pointer.
    ^: Two operands phase is false, different to true; moreover | when the operand is a boolean XOR operation is bit
  34. Value '3 << 2' 'value, a value of 3 ~: '12 >> 3
    3 0b10100b0101: Results of 4
    ' 3 2 2 ', 2 3 binary left shift of two, the result is 12
    '12 / 2/2/2 ', 3 binary 12 position 3 has the right movement. the result is 1 Similarly, '12 >> 4' result is 0
  35. String concatenation operator "+" Rule:
    as long as a String type when the two operands, the system will automatically the other operand is converted to a string and stitching.
  36. Operator Precedence:
    General logical NOT "logic" OR
    A || B && C actual calculation is: A || (B && C)
  37. Automatic conversion of data types:
    Here Insert Picture Description
    Here Insert Picture Description
    pay attention to the range of the number of literals, if the default is not more than 2.1 billion int range
  38. The concept of a cast:
    also known as modeling (descending): used to display the conversion of a value type, you may have missing information may result in reduced accuracy or overflow.
    (Type) var
    when the type of the target range occur, will be truncated to different values (typically in the range of the cycle)
    can not be made between the cast and the boolean any numerical type.
  39. Java classes and common keyboard input methods:
Scanner   scanner =  new Scanner(System.in);
String   name =  scanner.nextLine();
int   age = scanner.nextInt();
  1. Free flow control statements:
    sequential structure, selection structure, a cyclic structure
  2. The nature of the program:
    variable, select statement, loop statement
  3. The basic configuration of the algorithm:
    variable selection structure, sequential structure, a common support structure of the cyclic basic structure of the algorithm
  4. Classification selection structure:
    the If selection structure: if a single selection structure, if-else double-selection structure, if-else if-else multiple selection structure
    Switch selection structure.
  5. Obtaining a random number between 0-1,
    Java.lang.Math.ramdom (); may generate a [random number between 0 and 1).
  6. If the single branch if not effect subsequent write {} execution code:
    executes a first statement later.
  7. If-else sometimes be replaced by that way:
    1> 2 "false": "true"; conditional operator?.
  8. If-else if-else structure of the execution order more choices, and prepare recommendations:
    the order of execution: from top to bottom, Yuzhen into the execution and return
    to prepare recommendations: condition not to subsequent branch and the first order conditions intersection. Layer progressive, need to sort out the order.
  9. switch multiple choice grammar structure, the implementation of the principle:
switch (表达式) {
case 值1: 
语句序列1;
[break];
case 值2:
 语句序列2;
[break];
     … … …      … …
[default:
 默认语句;]
}

Depending on the value of the expression, that matches the case at the beginning of the implementation of the label, has been implementing to break at the statement or the end of the statement. If the match has not, the process proceeds to default (default when present)
types available in the expression 50. switch:
JDK1.5 before: must be an integer, except Long; or enumeration, not a string
after jdk1.7: may String
current expression may be: byte, short, int, char , enumeration; Stirng (1.7 or more)
51. IF multi-branched and multi-branched switch is used to distinguish:
any switch can be more branched multi-branched replaced by if;
table interval judgment when only enough if many branches;
recommended switch branches clear when the value is clear to do the equivalent of judgment.
52. The structure of the classification cycle:
When type: Boolean expression when the condition is true, repeatedly executes a block of statements when the expression is false only to stop the cycle. While / for
up to type: first execution of a sentence, and then determine the Boolean expression. If true, execute again. Repeatedly, until the stop Boolean expression is false. The while-do
53. Note the use of the While loop points:
start of the cycle i.e. the Boolean expression is determined. First implementation of the first judgment
statement should be the end of the statement cycle trend, or an endless loop.
54. do-while loop using the attention points:
First statements are executed once, and then determine the Boolean expression. After the execution judgment
statement should be the end of the statement cycle trend, or an endless loop.
55. for loop syntax, the statement execution order:
for (initial expression; Boolean expression; iteration factor) {
loop body;
}
A. Set initial value of the loop variable initialization section
B. Conditions arbitrary boolean expression judging portion
C. loop (may skip)
D. Iteration controlling increase or decrease of the loop variable factor
B. . . . . .
56. for the difference between the cycle and while, dowhile of:
for loop: Support the general structure of iterative, flexible and effective, before the first iteration, you need to perform initialization, and then determine the Boolean expression; then execute the statement; after executing, will performing iterative step factor; (initialize, and then determines, after performing the last iteration)
the while: not supported iterations, the iterative manual, performed after the first determination;
do the while-: does not support iteration, the iteration manually, after performing the first determination.
57. java comma separators commonly used where:
a plurality of variable declarations; loop for initial expression; Boolean expression; a plurality of iterations dividing factor; a plurality of interface; formal and actual parameters segmentation list
58. for loop whether the cycle may be empty:
can, but use two separated by a semicolon represents into an infinite loop
59. the double-nested loop for understanding:
number of outer control lines, control the number of inner columns
60. Continue and break distinction
break: for controlling the flow loops, forcibly exit the loop, the loop does not execute the rest of the sentence; Further, switch to break multi-branched interrupted branch statement. The following statement is not in progress
Continue: used to terminate a process cycle, the cycle skip the rest of the sentence, the next cycle is turned on, for statements need to perform an iterative step factor, and while in direct jump back dowhile header cycle.
61. The break and continue tabbed usage:
Since the java goto is a reserved word, to get out of the current cycle requires the use of a multi-layer break and continue tabbed
usage:
(only) before the loop, add "tag name:" in the form of a statement out of position; by using a loop: do out of braek tag name or tag name of the form continue.
62. The definition of a block of statements, nested statement block can declare a variable with the same name do:
also known as compound statement, {} with any number in braces java simple sentence, determines the scope of local variables, block program code to be executed as a whole. And the block can be nested.
Can not.
63. The method defined:
for a specific function completion code segment;
for behavioral features and functionality of the classes and objects achieved.
The method is an abstract class and an object behavior characteristics.
Is the basic unit of the java program, classes and objects belonging to the method.
64. A method invocation:
Object Name method name (argument list); here, the object name is a reference to an instance address actual
static process side also be directly invoked by the class name. Examples of non-static method must be called, is not common to see the inside of an object class is added by default because there is this pointer indicates the object currently created.
65. Notes the method used:
actual arguments, the same form of data types, and methods must be declared in the order parameter.
Return statement terminates illegal operation and return the required type of data. Use a void return type do when there is no return value.
Java method calls pass parameters, follow the value transfer (a copy of all data transmitted, the data reference type is a copy of the address of)
the basic type of transfer is copy the value of the data value of
a reference type is passed copy of the value of the target application, but pointing to the same object.
Here Insert Picture Description
66. The method of overload: overload define:
a class to be defined in the same multiple method name, but different parameters of the method. When invoked, the method of automatic matching corresponding to the different parameters.
67. The configuration method overloaded conditions:
overloaded method, it is actually a completely different approach, but the name just not the same!
Different: formal parameter types, the number of formal parameters, the order of the formal parameters
only return values are different, the method does not constitute a heavy load, it will be reported anomaly. (Not according to the return value is determined based)
that differ only in the name of the formal parameters of the method does not constitute a heavy load. (Meaningless)
Here Insert Picture Description
Note automatic conversion type.
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
68. The method call, when it comes to matching method overloads:
by type of the actual parameters of the called method, first by the original line type matching, if not, follow automatically converted to match the type of rule, and follows a small cross-level principles. If none exception.
Here Insert Picture Description
69. The basic idea of a recursive algorithm, composed of:
calls itself
70. recursive definition of head: no longer tell when to call the method itself. If it will not end into an infinite loop.
71. recursive definition of the body: the actual need for specific treatment method recursive processing, business process statement, while demonstrating recursive calls.
Seek n !;

public class TestRecursion{
		public static void main(String[] args){
				long n = 100;
				System.out.printf("%d阶乘的结果:%s%n", n, factorial(n))
		}
		static long factorial(long n){
			if(n==1){//递归头(尽头)
				return n;
			}else{
					return n*factorial(n-1);//递归体  //实际就是  n * (n-1) 这里的n-1就是//需要通过递归求取的  
			)
}
}

Call principle:
Here Insert Picture Description
the advantages and disadvantages 72. recursive:
a little: the program is simple and easy to understand, easy to understand and debug, without emphasis on efficiency, with recursion.
:( disadvantages time-consuming and memory) intensive system stack; memory consumption and more; when the call level for a long time, which is much slower than the cycle. In addition to solve any problem with a recursive use of loop iterations can be resolved. When the high performance requirements, with circulation.

Published 37 original articles · won praise 29 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42755868/article/details/104873492