Java all-round learning

xiaoxiao2021-03-06  75

Java 2 All-round learning J2ME Wireless Java application development Java mobile phone program design Getting start and application 1. For a general PC platform, Java's program is divided into two categories, one is a Java Application directly running directly on the PC's operating system. The other is a Java Applet running through the JVM included in the browser. 2, . 3, Javac, Java, AppletViewer. 4, Java is using Unicode as a character set, so we use Chinese or English or even other languages ​​in the Java program as the Class name, and the variable name can be. 5, JFC-Java Foundation Classes, Gui-Graphical Uesr Interface. 6, java -jar java2d.jar. 7, PDA-personal data processing. JPDA-Java Platform Debugger Architecture.

Chapter 4 Program Basic Unit 8, the difference between keywords and reserved words. Magic of the flag. The meaning of Literal. The meaning of variables, the principle of variable naming. 9. Basic data types: integer, floating point, other types. 10. Why is the positive and negative value of the numerical range, unreasonable or infinite number of indications. Its core is a precision problem. The floating point does not exist 0 values, so errors will be generated. 11, other data types: Boolean, CHAR, common escape character, special character representation. 12. The pattern of two variables of Java: Member variable, local variable (LOCAL VARIABLE). The initial value of the member variable is specified in the statement. The local variable will not request the user to set the initial value itself. 13. Type conversion is divided into automatic type conversion and mandatory type conversion (CASTING). Each of them is divided into two kinds in widening and narrowing. The zoom conversion belongs to the automatic type conversion and reduces the conversion belongs to the mandatory type conversion. 14. After the data type, add an English letter because Java is related to the LITERAL default data type, basically Java's LIERAL default is int type, and the Literal default for floating point numbers is Double. 15. There is a special class in Java, which can be used like a general basic data type, which is a string-string.

Chapter 5 of Java expression 16,5% 2 and 5% -2 and -5% 2 and -5% -2 are distinguished. 17. The result of the comparison operator has only two, true and flase. INSTANCEOF? 18, logic and generality differences. When you need to change the value of the variable, use generally. Usually use logic operators because the speed is fast. 19. The priority of logical operations is under the comparison operator. 20, the assignment operator is the lowest in all operators. The assignment operator is run from the right side. The arithmetic operator is from the left to the right. And the left side of the assignment operator can only have one variable. 21. Bitwise. &, |, ^, ~ (Complement). The bit operator can only be used in the integer data type. Displacement operation (SHIFT). The displacement is more difficult. To understand the use of displacement operations. Understand the meaning of the reduction operation. 22, priority and combination of operators.

Chapter 6 Java's statement 23, the statement has many kinds, roughly divides them into four categories: The first category is a general statement, the second class is a statement statement, the third category is the conditional process control statement, the fourth category is Cycle control statement. 24. The declaration of the subjects and variables is different. Objects must be instantiated after the declaration, and variable declarations are unnecessary. 25,?: The use of the operator. 26, the parameters of Switch can only be one of (). 27, for ( ) { S}. Don't use floating point numbers as control variables. Due to the problem of floating point. 28, WHILE ( s}. 29, do { s} while (. Taking a colon: as the end. Use the appropriate Break, Continue and token to enhance the elasticity of the program. But don't use token. 32. The use and restrictions of comment statements, if statements, Switch statements, cyclic statements, Break, Continue, and tags must be understood. Chapter 7 Java Object Design 33, the object is an instance that is in line with a certain type of definition (Instance). The class is abstract, and the object is actually. Attribute is used to describe an instance object, actually the variable. Method is an object that is your own behavior or the method of using them, is actually a function. Attributes and methods are called members of the object. Class can be said to be a blueprint, and some properties and methods that must be provided when many generated objects are defined. 34. Inheritance and Polymorphism are the other two important features of the class. The main purpose of inheritance is to "expand" the original class, strengthen or improve the attributes and methods defined by the original class. The inherited class is the parent class, inherited class as subclasses. Using the expression of UML (Unified Modeling Language), you can draw a class diagram, the most important part is class icon and inheritance icon. The concept of polymorphism is more embarrassed, and it is necessary to enhance understanding, there is also a concept of override. 35, in order to enhance the readability and ease of use. The Java programmers in the world abide by the following rules: (1) Package (package), all the words of the Package name should be lowercase; (2) class, each English word uppercase; (3) interface , The rules are the same as the class; (4) attribute, the first letter lowercase of each English word, the first English letter uppercase of other words; the method, rules, and attributes, but there are small parentheses; (7) Constant, all the English words are all capitalized, and each two English words are separated by underline. 36, two classes of Animal and Zoo only need to compile ZOO.JAVA. This is because all those used in zoo.java have not been compiled yet, they are automatically compiled in the process of compiling zoo.java.

37. Constuctor, in addition to automatic generation of us when compiling in Java, you can write the required constructor yourself. The constructor is also a way. 38. In a class, there are multiple constructor use the same name, but the parameter type and number are different, and we call such a behavior to the constructor overload. 39. In principle, two rules must be observed: First, the name name must be the same. Otherwise, it is two different methods that cannot be called overload. Second, the type of parameters called must be different. Because the compiler is to determine which method is called by the parameter type. 40. A very important concept of object-oriented programming, we call information hidding, dedicated technical terms are encapsulatio. The purpose of the package is two: 1. The data in the protection class does not allow these data to be used or destroyed; Second, hidden does not need to let others know the details to prevent misuse of others. There are still other important features of the package: the specific details of the hidden class; forced users to access data through a single interface; program easier maintenance. 41. Naming Rules for Attribute Access Method: The method of setting the property value is started as the beginning; the method for obtaining the attribute value is started as the beginning; the Boolean data type value is naming in the form of ISXXX. 42. Polymorphism, spectrum spectrients, can be seen as different classes in different situations. 43, class members and instance members. The properties and methods described above are subject to the object level, called instance members. Class members must use defining words Static. The calling method of class members is . , or the . . However, instance members cannot be used in the class method. 44. When the subclass generates an object, it will notify its parent class, and its parent class will inform the parent class of the parent class, continue this operation until the top of the Java.Lang.Object class. Informing the most important purpose of the upper parent class, the initialization is initialized for those attributes or other settings that inherit from the parent class. This is also the purpose of inheritance of the reuse of the program code. Java automatically helps us with the program code that inform the parent class, is added in the constructor. Super (); the meaning of this line must be understood. Super is a keyword. 45. Call the Super function must pay attention to two points: 1. Super call must be in the first line of constructor. Second, if there are several different constructor in the subclass, the second parent class has no constructor that does not require parameters, then the appropriate super call must be added to the first line of each constructor in the subclass. 46, constructor call constructor with this keyword. 47, Super and this have some places to pay attention to: 1. Super and this can only use the first line in the constructor code code; Second, Super and THIS can only use one; three, super and This call can only be used in the constructor; four, if you don't use Super or this in the constructor, then Java will automatically help you add a super () call. 48, Shadow - Property (Inherment), Override - Method (Inheritance) - Overload - Method (Same as the same name, but the parameters are different). Several methods of using properties must be understood, super, this, forced type conversion.

Chapter 8 Deeps into the Object Design 49 in Java, what is package (package)? The package is very similar to the directory in our computer or a folder. Directory separator, DOS /, UNIX. The catalog mechanism is applied to the Object-oriented program of Java. 50. In the package statement, the original directory separator is replaced by the period [.]. Package You must pay attention: The package statement must only write the first line of the program code. Package's UML icon. In addition to the first row of the Java file in each class sets the package, the program code is used in other classes, and the name of its package is also added. Setting and use of package. 51. The Import statement must be written after the Package statement, before all classes declare. Wildcards for the Import statement (*). Using wildcards just incorporated in the class IMPORT under this package, it does not come in to the class import in the subdirectory. 52, set of classpath. ClassPath is a [Environment Variable] that the Java program is compiled and runtime. Its main purpose is to tell the compiler to find the class required to compile or runtime. Windows defaults ClassPath is [.]. Set two methods of ClassPath: 1. Direct settings; Second, Javac plus -classpath this parameter. 53. Use of qualitative words for access rights. Use of Protected with default. There are four words in the parity limit, and the class declaration is only two. 54. Use of final qualifiers - for constants. Used in Final and Static. 55, the use of abstract classes. The keyword is Abstract. The subclass of the inheritance must cover a particular method, this mechanism is [Abstract]. In a class, we can specify a method as abstraction, and an abstract method does not need to write the content of the method, that is, when the method is declared, it will end directly with a semicolon [;], no need to add Left and right braces. As long as there is any abstract method, then this class must be an abstract class, so we must add the statement of the category with Abstract this keyword. Abstract classes cannot generate an object instance. Abstract can only be used in classes and methods. There is no meaning on attributes and variables. 56, interface - a standard, some specification. In Java, the interface is composed of some constants and abstract methods. The keyword is [interface], the format used is as follows: Interface [Extends S]. Solve problems that Abstract can't be resolved. The syntax statement of the method in the interface is the same as the grammatical statement of the abstract method. It is only the method of the method, and there is no method itself. . The method in the interface is also all abstract methods, just do not need to add Abstract this keyword. Extends , Implements . Simply put, the interface is a fully abstract class. Java uses multiple interface methods to complete the multiple inheritance mechanisms of the class. Implements , ....... There is a special interface in Java, which only has a declaration of the interface, and inside is empty, that is, there is no statement of constant and methods. This special large number of interfaces are called the [Marker Interface].

Chapter 9 Common Methods of Object Class Introduction 57, comparison between objects, first view, object phase, etc., refer to the same one. Includes memory used. Use == directly. The second point of view is whether the contents of the two objects are equal. Use the equals method. 58. Understand the meaning of Hash Code. 59. Reference (Reference) and CLONE. Use of Clone methods. 60. Method of converting objects into characters [toString]. 61. When the design is designed, it is best to cover these Object's methods.

Chapter 10 Deeps into memory 62, the use of variable memory, and the compiler is allocated in memory. 63. After the memory of the object, after the object declaration, the compiler is only a reference to an object in memory. It is not a real object instance because the object's instance we have not generated. So when an object is declared, the initial value referenced by this object in memory is [null]. We use the new keyword, with the calling class constructor to generate an object instance. However, this time the object reference and the object instance are not associated. You need to use a replication statement to associate them. Each object references the 4 bytes of memory space. The reference to the object is stored is the address of the object instance in memory. Object references the actual memory size, related to system (JVM) implementation, different system sizes are not necessarily the same. 64, what is an array, array is a large amount of storage, the same properties, and needs to be done. Arrays can be used on variables of basic data types, of course, can be used on objects. The array is a bit similar to the object, divided into two phases - array references and array instances. The array declaration format is as follows: int a []; and int [] a; the array declaration is completed, the method in memory is the same as the object, and is also a reference, and the initial value is NULL. Generating an array instance is also used to use the NEW keyword, after which the assignment statement is used to associate. You can also create and initialize array, such as int a [] = {1, 2, 3, 4}. 65. The index of the array (index) is [], which represents the first few data in this array. The array is relatively simple, that is, after the name of the array variable, add the index to access. The index starts from 0 to the size of the array 1.66, the length of the array gets the size of the array. It must be noted that the size of the array cannot be changed. It is more elastic in use. 67, the replication of the array. The array is not an object that inherits from the Java.lang.Object class, so there is no way to copy the object instance. You can use a cyclic assignment. [System.ArrayCopy] method is provided in Java. 5 parameters are required when using this method, which is the number of source arrays, source array data start positions, destination arrays, destination array data start positions, and reproduction data. It is more elastic in use. The ArrayCopy method is only available for arrays of basic data types. In contrast, the second method uses JNI method, so the speed will be faster. ArrayCopy's three exceptions, nullpointersexception, arrayindexoutofboudsexception, arraystroeexception. 68. Java Native Interface (JNI) is a native programming interface that is part of the Java Software Development Kit (SDK). JNI allows Java code to use code and code libraries written in other languages ​​(such as C and C ). The Invocation API (part of JNI) can be used to embed Java Virtual Machines (JVM) into the native application, allowing programmers to call Java code inside the native code. All examples of preparatory knowledge are written using Java, C and C code and can be ported to Windows and Based on UNIX. To fully understand these examples, you must have some Java language programming experience. In addition, you also need some C or C programming experience.

Strictly speaking, the JNI solution can be divided into Java programming tasks and C / C programming tasks, which completes each task by different programmers. However, to fully understand how JNI works in two programming environments, you must be able to understand Java and C / C code. System Demand Browser: Netscape 4.x or later, or Internet Explorer 4.x or later, support JavaScript. To run an example in this tutorial, you need the following tools and components: Java compiler: Javaac.exe provided with SDK. Java Virtual Machine (JVM): Java.exe provided with SDK. This machine method C file generator: Javah.exe provided with SDK. Define the jni library files and this unit file. JNI.H C header files, JVM.LIB and JVM.DLL or JVM.SO files are provided with SDK. Create a shared library C and C compiler. The most common two C compilers are Visual C for Windows and CCs for UNIX systems. 68, the color of the multidimensional array in memory. It must be understood. Generation of irregular arrays. The irregular arrays are an important feature of the Java language. Other programming statues C or Basic can only declare the multidimensional array of rules, and the dimension has the upper limit. Java has no restrictions. 69, the array of basic data types is discussed, and the object array is now. Prevent NULLPOINTEREXCEPTION is abnormal. 70, the access range of the variable [scope], a bit of a bit of a bit of the property and method access, which is a combination of access to the limitations of access, Package, and inherit these relationships. Variable access range is roughly divided into four levels: first, class (static); second, object instance stage; third, method level; fourth, local level. How to distinguish these levels, you must pay attention. These four levels must be understood. The relationship between access and field of view is just the opposite. The memory exists. 71, the passage of the parameters. There are two ways to pass the previous programming language concept parameters. First, the other is the "call by reference]]. But Java is only valuable in this way. Basic data type parameter value passes is different from class object type parameter values. 72, Garbage Collection. Responsible for running this mechanism is [Garbage Collector]. Object declarations include two parts: object references and object instances. If an object instance is not referred to by any object reference, but when the GC is started, the object instance is reclaimed and the memory is released. Cancel the object reference, as long as it specifies it to [NULL]. The GC is not currently start, or manually call it, the method is [system.gc ()], which will call [Runtime.Getruntime.gc ()], both of which can be used. The Finalize method is also a method commonly used by the Object class, which is related to GC. It is the method called before the object is recycled, and the GC is called. The sequence of reclamation is related to the generation order of the object instance. It is not only what we manually call system.gc (), and GC is not necessarily run, and the correct startup time of GC cannot be known.

Chapter 11 Application and Applet73, the output of Application, the OUT attribute of the System class is the PrintStream object, with the Prinlin method and the print method, or the ERR property is a printStream object, there is a Prinlin method and a Print method, but different, OUT property can Redirected, the ERR property can only be output to the default device. Application Default is the open command line window, Applet default is Java Console. You can use> to achieve redirection. Both the Println and Print methods are overloaded methods. In addition to accepting eight basic data types and String types as parameters, they can accept general objects as parameters, and the compiler will automatically call the [toString] method of this object, char An array can also be used as parameters of these two methods. 74. The input of Application is divided into two, one is the parameter input (command line parameters), the use of the Wrapper class. The basic data type corresponds to the correspondence of the Wrapper class. Wrapper class has a corresponding Parsexxx method to implement strings to convert to basic data types. Second, the standard input, the System class in property is an inputStream object. There is an read method to read the input, and read it is Byte to the type, you need to convert to another class data. Usually use the InputStreamReader class, then connect to the BufferedReader class, the method of reading a string provided with the BufferedReader class [Readline]. 75. The acquisition of the system parameters is used in the [System.getProperties] method. Must pay attention to the difference between system parameters and command line parameters. 76, the use of the System class. The difference between setXXX (SetOut, setr, setin), setproperties, and setproperty. System.exit (n), the virtual opportunity calls the runtime.getrutime.exit (n) method. CurrentTimeMills. 77, the use of the Runtime class. You can run an external program through the method of EXEC. 78, AppPlication must have a method of main, in line with four conditions. And an applet must inherit the java.applet.applet class. The main method is the starting point of the Application running, and the starting point of the Applet runs on the init method. APPLET, System.out or System.err method is output, but the System.in method cannot be used. Applet has its own input method, similar to the way of command line parameters. In the HTML file, plus the parameter syntax, value = >. Then in the Java program, apply the [getParam] method of the java.applet.applet class. 79. The use of the applet fundamental method. INIT, Start, Stop, Destroy, Paint. The difference between the DESTROY and FINALIZE methods is different from the location. The use of the Paint method. There is an attribute in the PAINT method being a Graphics object, pay attention to the use of the [DrawString] method of the Graphics class. 80, Java security, refers to the APPLET to meet the US-based security specification specified by Java. Four points limit measures. 81, the combination of Application and Applets.

Java Web Start is a mechanism for replacing the applet. Chapter 12 Exceptions 82. Exceptions In the process of running, due to writing programs, external environments, or computer system itself, it can cause errors when the program is running, causing crash or The calculated results are incorrect, and these bursts are called abnormalities. Abnormal processing means that some strain processing can be made when the program has an abnormality. 83, Java.lang.Throwable class. Exception class (can be controlled) and an Error class (uncontrolled). 84, RuntimeException common are the following: ArithmeticException, ArrayIndexOutOfBoundsException, ArrayStoreException, ClassCastException, IllegalArgumentException, NativeArraySizeException, NullPointerException, SecurityException. Because of its own programming. 85. CHECKEDEXCEPTION has the following: ClassNotFoundexecption, FileNotFoundException, InterruPedException, IOException, Sqlexception. Some external factors are caused. 86. Erro has OutofMemoryError, StackoverflowError, UnknowError, AWTERROR, ThreadDeath. System-level and very serious mistakes. The cause of the error is that it is insufficient or hangs when running. 87, capture and processing exceptions. It is mainly an exception for the CheckedException class. Try, catch, finally three keywords. Processing exceptions include the following two steps: 1. Display the exception's name and some related information, II, use the most secure method to recover the operation of the program. Display exception information is used, toString, GetLocalizedMessage, GetMessage, PrintStackTrace method. The PrintStackTrace method has three different overloads. Flexibility. Finally keyword Note The following three points: 1. There is no exception production - "Enter the Finally Block -" The unruly program code remains. Second, there is an abnormally generated - "Capture -" Enter the Catch Block - "Finally Block -" method remains unruly program code; three, there is abnormal production - "No capture -" Enter the Finally block - " There is no running program code in the method. 88, pay attention to the order of abnormal capture. The more above, the more it is below. 89, the use of the THROWS keyword, the method declares an exception. The THROW keyword is thrown inside the method. You must pay attention to the difference between RuntimeException and CheckedException two exceptions. 90, define your own Exception. 91, throw an abnormal method coverage. Note Two points: First, the original method throws an abnormal parent class or superior class; Second, the number of abnormalities throwing cannot be thrown more. It is mainly because the anomaly classes thrown at time cannot be automatically converted into the unusual class declared in the parent class.

转载请注明原文地址:https://www.9cbs.com/read-87704.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.054, SQL: 9