, such as an integer large enough to subtract a negative number large enough, results in an overflow. Causes a memory leak.
What is the mechanism for implementing polymorphism in Java?
The method has the same name, and the method has a different number of arguments or types. Java garbage collection is primarily a garbage collection of dynamic memory, typically when the memory is not enough to be garbage collected, or through System.GC () to notify the system for garbage collection. But it does not necessarily guarantee execution.
A static variable can only be a static method to call him.
Super.clone (), which is the default behavior of the Clone () method, because the members in the parent class are first copied before they can be copied.
One of the advantages of the Java language is that it cancels the concept of pointers, but it also causes many programmers to ignore the differences between objects and references in programming, especially the programmers who learn C and C + + after java. And since Java cannot solve the problem of object duplication by simply assigning values, it is often used in the development process to replicate objects using the Clone () method. For example, when a function parameter type is a custom class, it is a reference pass instead of a value pass. Here is a small example:
- Public class A implements Cloneable {
- Public String name;
- Public Object Clone () {
- A o = null;
- try {
- o = (A) super.clone ();
- } catch (Clonenotsupportedexception e) {
- E.printstacktrace ();
- }
- return o;
- }
- }
-
- A a1=new A ();
- A a2=new A ();
- A1.name="A1";
- A2=A1;
- A2.name="A2";
- System.out.println ("a1.name=" +a1.name);
- System.out.println ("a2.name=" +a2.name);
Java can cause memory leaks, polymorphism, garbage collection, clone