converted, and String. valueOf (Object. These methods are analyzed one by one. Method 1: Use the Object # toString () method. See the following example: Object object = getObject (); System. out. PRintln (object. toString (); in this method, Because java. lang. the public method already exists in the Object class. toString (), so this method can be called for an
and automatic unpacking.
Automatic boxing/unboxing greatly facilitates the use of basic types of data and their wrapper classes.
Automatic Boxing : The basic type is automatically converted into a packing class (int >> Integer)
Automatic unboxing : Packing class automatically converted to basic type (Integer >> int)
For example, the following examples:
Imp
Document directory
1. Internal class
First, let's take a simple example. If you want to implement an interface, but a method in this interface has the same name and parameter as a method in the class you have conceived, what should you do? In this case, you can create an internal class to implement this interface.
Directory
Class Loader
Dynamic loading
Link
Initialization
Example
Class LoaderBefore you understand the mechanics of Java, you need to understand how the class is loaded in the JVM (the Java Virtual
-and text), parsing (text-to-date), and normalization. SimpleDateFormat allows you to select any user-defined pattern of date-time formats. However, it is still recommended to pass the gettimeinstance,getdateinstance , or dateformat in the getdatetimeinstance to create a date-time formatter. Each of these class methods can return a date/time formatter initialized in the default format pattern. You can use the applypattern method to modify the for
detached.
In the figure, the order of loading, verification, preparation, initialization, and uninstallation is determined. The loading process of classes must start step by step, while the parsing stage is not necessarily.
2. There are only five types of requests that require "initialization" (loading, verification, and preparation must start before) for the class immediately:
① In case of four bytecode commands, new, gerstatic, putstatic, or invo
Directory
Class Loader
Dynamic loading
Link
Initialization
Example
Class LoaderBefore you understand the mechanics of Java, you need to understand how the class is loaded in the JVM (the Java Virtual
1. Subclasses after the instance is created, the class initialization method calls the parent class's initialization method (except for the Java.lang.Object class, because the Java.lang.Object class does not have a parent class), and the call is traced back to the Java.lang.Object initialization method.This place I'm t
cannot obtain ExtClassLoader because it is implemented in C ++.3. Parental Appointment Mechanism
When receiving a request for loading a class, a specific class loader first delegates the loading task to the parent class loader.Delegate a load task to an upstream NodeUntil the parent class loader, if the parent
classes in Java
Class can be viewed as a template for creating Java objects.
Understand the definition of classes in Java by following a simple class: public class Dog {String breed; int age; String color; void Barking () {} void
declared as public or not, but the results will be processed according to the Public type.
5. When implementing an interface, you must declare the defined method as public. Otherwise, it is the default access type, which is not allowed by the Java compiler.
6. If all methods in the interface are not implemented, an interface is created.
7. Extend an interface to generate a new interface using the keyword extends to implement an interface using implem
Inheritance relationship inheritance refers to the ability of a class (called a subclass, sub-interface) to inherit the functionality of another class (called the parent class, parent interface) and to increase its own new functionality. Inheritance relationships in Java are clearly identified by keyword extends and ar
parameter is as follows:SRC: Represents the source array.Dest: Represents the target array.Srcpost: Represents the starting position of the copied element in the source array.Destpos: Represents the starting position of the copy to the destination array.Length: Indicates the number of copied elements. It is important to note that in the case of array copying, there must be enough copies of the elements in the source array to exist, and the target array must have enough space to hold the copied
Java File class learning notes 2: File class objects and common operation methods, file learning notes
1. File, relative path, and absolute path
1. File(1) standard files: such as images and music files.(2) directory file: a folder.(3) virtual memory files: temporary files generated by the system during program running.
2. File Path(1) Relative Path: compared wit
basically the same, it is very simple, is put method to the object into the map, and get can take the object in the map, but it is wrong to try to use the two-tuple hashmap, if an object contains too many elements, then you should consider using classes. Instead of being obsessed with Java mediations, the collections class between common variables and class clas
extended classpath by including a portal named Class-path (which contains a list of files and directories). JDK 1.3 introduces the Class-path manifest portal for specifying optional jar files and directories that can be loaded as needed. Here is an example of a Class-path entry:
The difference between inner class and anonymous inner class in Javainner class: The inner class can be static or non-static, static and static class variables can only be included, only static elements of the outer class can be a
corresponding initialization method (the replication mentioned here should actually be compiled, But it is said so for your better understanding ).So how to record the parent class of the initialization method is also related to the structure of the initialization method. The execution sequence and structure of the initialization method are as described above, however, the first execution command of each initialization method is to call another initi
Java study note 12 --- parent class Object Reference pointing to Child class object, learning Note 12 ---
What happens when the object reference of the parent class does not point to the object of the parent class, but to the object of the subclass?
Assume that the parent
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.