Java omni-Directional learning __java

Source: Internet
Author: User
Tags bitwise bitwise operators finally block garbage collection logical operators wrapper java web

Java All-round learning

Java 2 omni-directional learning J2ME Wireless Java application Development Java Mobile Phone Program design Introduction and Application
1, for the general PC platform, the Java program is divided into two categories, one is on the PC operating system through the JVM directly running Java application, the other is through the browser with the JVM running Java applet.
2, <applet code= "The name of the class file to run Width=" the width "height= displayed height" ></applet>.
3, Javac,java,appletviewer.
4, Java is Unicode as a character set, so we use in Java programs in Chinese or English or even other languages as class name, 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 4th the basic unit of Procedure
8. The difference between the key word and the reserved word. The magic of the marker. The meaning of literal. The meaning of variables, the principle of variable nomenclature.
9, basic data type: integral type, floating point, other types.
10, why the value range is negative and separate, irrational number or infinite decimal representation problem. Its core is the problem of precision. Floating-point numbers do not have a value of 0, so there is an error.
11, other data types: Boolean,char, commonly used escape characters, special character representation method.
12, Java Two kinds of variables mode: member variables (members variable), local variables (regional variable). The initial value of a member variable is specified when it is declared. Local variables, however, do not require the user to set their own initial values.
13, the type conversion is divided into automatic type conversion (promotion) and coercion type conversion (casting) two kinds. Each of these is divided into amplification (widening) and narrowing (narrowing) of two. The magnification conversion belongs to the automatic type conversion, and the narrowing conversion belongs to the coercion type conversion.
14, the data type is followed by an English letter, is because Java for literal default data type, basically java to integer lieral default to int type, and for floating-point number literal default is double type.
15, there is a special class in Java, you can use the same basic data type as the general, it is string-string.

5th Chapter Java Expressions
16, the difference between 5%2 and 5%-2 and -5%2 and -5%-2.
17, the comparison operator results in only two, true and flase. Instanceof?
18, the difference between the logic and the general. When you need to change the value of a variable, use the general and. Logical operators are usually used because the operations are faster.
19. The precedence of logical operations is under comparison operators.
20, the assignment operator is the lowest of all operators. The assignment operator operates from the right to the left. The arithmetic operator, however, operates from the left to the right. And only one variable exists on the left side of the assignment operator.
21, bitwise operator (bitwise). &,|,^,~ (complement). Bitwise operators can only be used in integer data types. The use of displacement operations (shift). Displacement operation is more difficult. To understand the purpose of the displacement operation. Understand the meaning of the subtraction operation.
22. Precedence and binding of operators.

6th Chapter Java Statements
23, there are many kinds of statements, roughly divided into four categories: the first category is a general statement, the second is the declaration of statements, the third category is conditional flow control statements, the fourth class is a circular control statement.
24, the Declaration of the object is different from the declaration of the variable. After the object has been declared, it must be instantiated, and the variable declaration is not required.
25,?: The use of operators.
26. The switch parameter can only be one of (<byte, short, int, or char variable >).
27, for (< control cycle variable initial value set >;< Loop end Judgment condition Statement >;< control Cycle Variable Value change method >) {< code >s}. Never use floating-point numbers as control variables. Due to the problem of floating-point error.
28, while (< loop end judgment Condition statement >) {< code >s}.
29, do{< Code >s} while (< Loop end judgment Condition Statement >).
30, advanced loop control-nested loops. And the use of break and continue.
31, marking <token> use. Ends with a colon:. Using appropriate break, continue, and token can enhance the flexibility of the program. But don't mess with token.
32, you must understand the use and restrictions of annotation statements, if statements, switch statements, loop statements, break, continue, and tags.

7th Chapter Java Object-oriented programming
33. The object is an instance (instance) that conforms to a certain kind of definition. The class is abstract, and the object is real. Attributes are used to describe an instance object, which is actually a variable. Method is the object's own behavior or the method of using them, which is actually a function. Properties and methods are called members of an object. A class can be said to be a Blueprint (blueprint), which defines a number of properties and methods that are necessary to produce such objects.
34, Inheritance (inheritance) and polymorphism (polymorphism) are two other important attributes of the class. The main purpose of inheritance is to "extend" the functionality of the original class, to strengthen or improve the properties and methods not defined by the original class. The inherited class is the parent class, and the inherited class is a subclass. Using UML (Unified modeling Language) to design classes, you can draw class diagrams, where the most important parts are class icons and inheritance icons. The concept of polymorphism is difficult to understand, and there is a need to strengthen understanding, including the concept of covering (override).
35, in order to enhance the readability and ease of use of the program. Java programs all over the world follow the following rules: (1) Package (package), as the Package name of the English words all want lowercase; (2) class, the first letter of each English word uppercase; (3) interface, Rule and class; (4) attribute, the first letter of each English word is lowercase, The first English letter of the other word is capitalized; (5) method, rules and attributes are the same, but parentheses are followed, (7) constants, English words are all capitalized, and each two English words are separated by an underscore.
36, Animal and zoo two classes only need to compile the This is because all the classes used in are compiled automatically when they are compiled, if they have not been compiled.
37, constructor (Constuctor), in addition to the Java compilation can be automatically generated for us, you can also write the required constructors. A constructor is also a method.
38. In a class, there are multiple constructors that use the same name, but the parameter types and numbers vary, and we call this behavior a constructor overload (overloading).
39. In principle, there are two rules to be followed: first, the name of the method must be the same. Otherwise, there are two different methods that cannot be called overloads. Second, the parameter type of the call must be different. Because the compiler is going to use the parameter type to determine which method is invoked.
40, object-oriented programming in a very important concept, we call the information hidden (information hidding), the special technical term for encapsulation (encapsulatio). The purpose of encapsulation is two: first, protect the data in the class, do not let the data be misused or destroyed; second, hide the details that you do not need to be known to prevent others from misusing it. There are other important features of encapsulation: the specifics of the hidden class, the forcing of users to access data through a single interface, and the ease with which programs can be maintained.
41. Naming rules for property access methods: Setting the property value begins with set; The method that gets the property value begins with get; the fetch of a Boolean data type value is named in isxxx form.
42, a class of polymorphic, refers to the class in different circumstances, can be considered as a different class.
43, class members and instance members. The properties and methods described earlier, which belong to the object hierarchy, are called instance members. Class members must use qualifier static. The invocation method for a class member is either the < class name >.< class member name, or the < object name >.< class member name >. However, instance members cannot be used in class methods.
44. When a subclass produces an object, it notifies its parent class, and its parent class notifies the parent class of the superclass, continuing this operation until the Java.lang.Object class is uppermost. An action that initializes an attribute or other setting that inherits from the parent class when notifying the primary purpose of the upper parent class. To achieve the reuse of program code, which is also the purpose of inheritance. Java at compile time automatically help us to notify the parent class of the program code, is added to the constructor. Super (); The meaning of this line must be understood. Super is the key word.
45, call the Super function must pay attention to two points: first, the super call must be in the 1th line of the constructor. If there are several different constructors in the subclass, and the two parent classes do not have constructors that do not require arguments, then you must add the appropriate super call to the first row of each constructor in the subclass.
46, constructor call constructor with this keyword.
47, super and this in the use of a number of places to pay attention to: A, super and this can only be used in the first line of the constructor program code; Two, super and this can only be used at the same time; a call to three, super, and this can only be used in a constructor; If super or this is not used in the constructor, then Java will automatically help you add super () calls.
48. Masks (Shadow)-attributes (inheritance relationships), overrides (Override)-Methods (inheritance Relationships), overloads (Overload)-Methods (with the same name as the same class, but with different parameters). Several methods of using attributes must understand the use of super, this, and coercion type conversions.

8th Chapter Deep Java Object-oriented programming
49, what is the package (package). The package looks like a directory or folder in our computer. Directory separator, DOS with/,unix/. The directory mechanism applied to Java object-oriented Programs is the so-called package.
50, in the package statement, the original directory separator instead of a period [.] To replace. Package <package name >; NOTE: The package statement must be written only in the first line of the program's code. UML diagram of the package. In addition to the first line in each class's Java file, the program code package the other class with its package name. Package settings and use.
51. The import statement must be written after the package statement, before all class declarations. The wildcard character (*) of the import statement. Using the wildcard character simply import the class under the package, not the import of classes in other directories in the directory.
52, the Classpath setting. Classpath is an "environment variable" that Java programs use when compiling and running, and its main purpose is to tell the compiler where to find the classes needed for compilation or runtime. Windows defaults to "." Classpath. Two ways to set classpath: first, direct setting; Javac Plus-classpath this parameter.
53. The use of qualifying terms for access rights. Use of protected and default. There are four member qualifiers, and the class declaration qualifier has only two words.
54. Use of final qualifier-for constants. Use of final and static.
55, the use of abstract classes. The key word is abstract. To allow inherited subclasses to override a particular method, this mechanism is abstract. In a class, we can specify that a method is abstract, and an abstract method does not need to write the content of the method, which means that when the method is declared, it ends with a semicolon ";" without adding the left and right braces. As long as there is any abstract method, the class must be an abstract class, so we have to add the declaration of the class to the keyword of abstract. An abstract class cannot generate an object instance. Abstract can only be used on classes and methods. There is no meaning on properties and variables.
56, interface-a standard, some specifications. In Java, interfaces are made up of constants and abstract methods. The keyword is "interface", using the following format:< qualifier >interface< Interface name >[extends< Interface name > S]. Solve problems that cannot be solved by abstract. The syntax declaration of a method in an interface is the same as the syntax declaration of an abstract method, that is, only the declaration of a method, without the method itself, simply by ending the entire statement with a semicolon, without adding braces. The methods in the interface are all abstract, except that the keyword is not required to be added to the abstract. Extends < class name >,implements < interface name >. Simply put, an interface is a completely abstract class. Java uses multiple interface methods to complete the multiple inheritance mechanism of a class. implements< interface 1>,< Interface 2&gt ... There is a special interface in Java that has only the declaration of an interface, and the interior is empty, meaning that there is no declaration of constants and methods at all. This special large interface is called the "markup Interface (marker interface)".

9th chapter of the common methods of object class introduction
57, the comparison between objects, the first point of view, object equality refers to the same object. Includes the memory used. directly with = =. The second view is whether the contents of two objects are equal. Use the Equals method.
58, understand the meaning of hash code.
59, the difference between reference (reference) and Replication (clone). Use of the Clone method.
60. The method of converting an object to a character "toString".
61, in the design of the class, it is best to also put these several object methods to cover.

10th Chapter Deep Memory
62, the use of variable memory, variable declaration, the compiler allocates memory.
63, the use of object memory, object declaration, the compiler is only in memory to produce an object reference (reference), it is not stored in a real object instance, because the object instance we have not yet generated. So when an object is declared, the initial value that the object references in memory will be "null." We use the New keyword to invoke the class constructor to generate an object instance. However, the object reference does not have an association with the object instance at this time. You need to associate them with the copy statement. Each object reference occupies 4 bytes of memory space. The object's reference holds the address of the object instance that is actually in memory. Object references the amount of memory that is actually consumed, related to the method implemented by the system (JVM), and different system sizes are not necessarily the same.
64, what is an array, the array is a large amount of storage, the same nature and need to do the same processing data. Arrays can be used on variables of basic data types, and of course they can be used on objects. Arrays are somewhat similar to objects and are divided into two phases--the declaration of an array reference and the generation of an instance of a group. The array declaration format is as follows: int a[]; and an int []a; array declaration ends, the method that behaves in memory is also a reference, and the initial value is null, as well as the object. Generating an array instance also uses the New keyword, which is then associated with an assignment statement. You can also create and initialize arrays, such as int a[]={1,2,3,4}.
65, the index of the array, is [] inside the number, which represents the first few data in this array. The use of arrays is simpler, after the name of the array variable, plus the index to be accessed. The index starts at 0 to the size of the array minus 1.
66, the length property of the array gets the size of the array. It is important to note that the size of the array cannot be changed. The use of a more flexible.
67, the copy of the array. The array is not an object that inherits from the Java.lang.Object class, so there is no clone of the method used to copy the object instance. Can be implemented using cyclic assignment. The "System.arraycopy" method is provided in Java. Using this method requires 5 parameters, followed by the source array, source array data starting position, destination array, destination array data starting position, the number of replicated data. The use of a more flexible. The Arraycopy method applies only to arrays of base data types. In contrast, the second method uses the Jni method, so the speed is faster. Arraycopy, Nullpointerexception,arrayindexoutofboudsexception, arraystroeexception. Three kinds of anomalies.
68. The Java Native interface (Java Native Interface (JNI)) is a native programming interface that is part of the Java Software Development Toolbox (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 the JNI) can be used to embed a Java Virtual machine (JVM) in a native application, allowing programmers to invoke Java code from within native code.
Preliminary knowledge
All of the examples are written in Java, C, and C + + code and can be ported to Windows and unix-based platforms. To fully understand these examples, you must have some Java language programming experience. In addition, you will need some C or C + + programming experience. Strictly speaking, the JNI solution can be divided into Java programming tasks and C + + programming tasks, with different programmers accomplishing each task. However, to fully understand how JNI works in both programming environments, you must be able to understand the Java and C + + code.
System Requirements
Browser: Netscape 4.x or later, or Internet Explorer 4.x or later, supports JavaScript. To run the examples in this tutorial, you need the following tools and components: Java compiler: Javac.exe provided with the SDK. Java virtual Machine (JVM): A java.exe that is provided with the SDK. Native method C file Builder: Javah.exe provided with the SDK. Defines the library file and the header file for JNI. Jni.h C header files, jvm.lib, and Jvm.dll or files that are provided with the SDK. C and C + + compilers that can create shared libraries. The most common two C compilers are Visual C + + for Windows and CC for UNIX based systems.
68, multidimensional array in memory appearance. Must understand. Generation of irregular arrays. Irregular arrays are an important feature of the Java language, and other programming languages, like C or BASIC, can only declare multidimensional arrays of rules and have a maximum number of dimensions. Java does not have this limitation.
69, the above discussion of the basic data types of the array, now look at the object array. Prevent the generation of nullpointerexception anomalies.
70, variable access scope "Scope", a bit like the class between the attributes and method access restrictions, these restrictions are due to access to the qualifier, package and inheritance of these relationships combined. Variable access scope is roughly divided into four levels: First, class level (static), second, object instance level, third, method level, four, local level. How to distinguish these several levels, must be noted. These four levels must be understood. The relationship between the scope of the visit and the view is just the opposite. The time that memory exists.
71, the transfer of parameters. There are two ways to pass a previous program language conceptual parameter, one is "value by call", and the other is "address by reference." But in Java there is only the way to pass values. The basic data type parameter value transfer is different from the class object type parameter value transfer.
72, Memory Recycling (garbage collection). In charge of running this mechanism is "garbage collector". An object declaration consists of two parts: an object reference and an object instance. If an object instance is not pointed to by any object reference, but when the GC is started, the object instance is recycled back and the memory is released for tuning. Cancels an object reference as long as it is specified as "null." The GC is an unscheduled startup, or it can be called manually by means of "System.GC ()", which invokes "RUNTIME.GETRUNTIME.GC ()", both of which can be used. The Finalize method is also a commonly used method of the object class, which is related to GC. It is the method that the GC invokes before the object is reclaimed. The recycle order is related to the order in which the object instances are generated. As we manually invoke System.GC (), the GC does not necessarily run, and the GC's correct start time is not known.                                                                                                                  & nbsp;                   
11th Chapter Application and applets
73, application output, the system class out property is PrintStream object, have Prinlin method and print method, also can use the Err property is PrintStream object, have Prinlin method and Print method, However, the Out property can be redirected (redirected) and the Err property is only exported to the default device. Application The default is the command line window that is open, and the applet defaults to the Java Console. You can use > to achieve redirection. Both the println and print methods are overloaded methods that, in addition to accepting eight basic data types and string types as parameters, can accept generic objects as parameters, and the compiler automatically invokes the object's "ToString" method. The char array can also be used as a parameter to both methods.
74, the application input, divides into two kinds, one is the parameter input (command line parameter), wrapper class's use. The corresponding relationship between the basic data type and the wrapper class. The wrapper class has a corresponding Parsexxx method to implement string conversion to the base data type. The second is the standard input, the in attribute of the system class is the InputStream object, there is a read method to read input, read in is byte type, need to convert to other class data type. You typically use the InputStreamReader class and then connect to the BufferedReader class, using the method "ReadLine" provided by the BufferedReader class to read the string.
75, the system parameter obtains uses "the System.getproperties" method. You must be aware of the difference between system parameters and command-line parameters.
76, the use of the system class. The difference between setxxx (SetOut, Seterr, Setin), SetProperties and SetProperty. System.exit (n), the virtual opportunity calls the Runtime.getRutime.exit (n) method. Currenttimemills.
77, the use of runtime class. You can use the Exec method to run an external program.
78, Appplication must have a main method, in line with the four conditions. and an applet must inherit the Java.applet.Applet class. The main method is the starting point for the application run, and the starting point for the applet to run is on the Init method. Applet, the System.out or System.err method is used to output, but the method is not available. Applets have their own input methods, similar to the way command-line arguments do. In the HTML file, add parameter syntax, <param name=< parameter name > value=< parameter Value >>. Then in the Java program, apply the "GetParam" Method of the Java.applet.Applet class.
79, the use of the basic method of the applet. Init, start, stop, destroy, paint. The difference between destroy and Finalize methods is that they are used in different locations. The use of paint methods. A property in the Paint method is a graphics object, noting the use of the "drawstring" method of the Graphics class.
80, Java security, refers to the applet to meet the Java designated security specifications. Four-point restriction measures.
81, the combination of application and applets. Java Web Start is a mechanism to replace applets.

12th Chapter Exception Handling
82, the exception refers to the procedure in the process of operation, due to the writing program of the sudden, external environmental factors, or the computer system itself, can lead to errors in the operation of the program, causing the crash or the results of the calculation is incorrect, these unexpected conditions known as abnormal. Exception handling means that when the program is abnormal, can make some processing of the contingency.
83, Java.lang.Throwable class. Exception class (can be controlled) and the error class (uncontrollable).
84, RuntimeException Common have the following: ArithmeticException, ArrayIndexOutOfBoundsException, Arraystoreexception, ClassCastException, IllegalArgumentException, Nativearraysizeexception, NullPointerException, SecurityException. caused by their own programming.
85, Checkedexception Common have the following: Classnotfoundexecption, FileNotFoundException, Interrupedexception, IOException, SQLException. caused by some external factors.
86, Error has outofmemoryerror, Stackoverflowerror, Unknowerror, Awterror, Threaddeath. System-level and very serious error. The reason for the error is insufficient memory or suspend at run time.
87, catch and handle the exception. This is mainly for exceptions to the Checkedexception class. Use of try, catch, finally three keywords. Handling exceptions includes the following two steps: First, the name of the exception and some related information display, two, the safest way to restore the operation of the program. Display exception information used, toString, Getlocalizedmessage, GetMessage, Printstacktrace methods. The Printstacktrace method has three different overloads. Elasticity (flexibility). Finally the use of the keyword note the following three points: first, no exception generation-"into finally block-" method left not running program code. Second, there is abnormal production-"catch-" into the catch block-"Finally block-" method left not running program code; Third, there is abnormal production-"did not capture-" into finally block-"method left not running program code.
88, attention to the order of abnormal capture. The higher the class, the more it is placed below.
89, use the throws keyword, throw an exception on the method declaration. Throw keyword, throws an exception inside the method. Attention must be paid to the difference in the use of throwing runtimeexception and checkedexception two of exceptions.
90, the definition of their own exception.
91, throws the exception method coverage question. Note Two: One, do not throw the original method throws the exception class parent class or upper class; second, the number of exception classes thrown cannot be thrown more than the original method. This is mainly because the exception class thrown at compile time cannot be automatically converted to the exception class declared in the parent class.

13th Chapter Container (Container) and layout (Layout)
92, what is AWT (Abstract windowing Toolkit), what is GUI (graphical user Interface) graphical user interface. The structure diagram of the AWT package.
93, container including frame and panel. The frame is constructed first, then SetSize, and then setvisible. Understand deprecation. A common method of frame. Remember the method of "Ctrl" + "C" to stop the program. A panel cannot appear on the screen independently, it must be placed in a container, such as frame or browser. The applet itself is a panel. The use of the Add method.
94, what is layout. "SetLayout (< Xxxlayout>)" method. There are five basic layout classes. The default layout for frame is the BorderLayout class. The panel default layout is FlowLayout. In addition, there are CardLayout, GridLayout, GridBagLayout. You can also design your own layout class.
95. The difference between pack and SetSize method.
96, if you do not use layout, you can use the "setSize" and "setlocation" method to replace. It is best to use the layout class.
14th Chapter Event Handling
97, what is the incident "event". Events are some of the actions that others give them. Understand the event-handling structure: The event itself, the source of the event's origin, and who handles the event.
98, what is the delegate processing mode "delegation Model". The mechanism of event handling.
99, the AWT event class structure chart. Divided into two categories: low-level and senmantic.
100, "Listener" This interface (interface) and "Adapter" class corresponds.
101. An object can delegate several classes to handle the same event, and a class that handles events can also handle events generated by different objects. This situation is called "multiplexer".
102, WindowEvent, MouseEvent, KeyEvent class Event processing interface, classes and methods. and other commonly used low-level event classes, respectively, are containterevent and focusevent.
103, Swing is another group of Java designed a richer, more functional GUI space. Understand the difference between swing and AWT.

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: 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.