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,
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 ( S}. Don't use floating point numbers as control variables. Due to the problem of floating point. 28, WHILE (
s} while (
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
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
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 =
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.