Way 1: Through the GetObject () method of the object class person p = new person (); Class c = P.getclass (); Mode 2: Gets a byte-code file object from the class name. Class (Any data type has a class static property that looks simpler than
Mainly from three aspects:
1 single inheritance
2 Multiple Inheritance
3 Virtual Inheritance
1 single inheritance
(1) A derived class fully owns the memory layout of the base class and guarantees its integrity.
A derived class can be thought
As you already know, the so-called read-only attribute means that the caller cannot modify this property. Unfortunately, this is not always valid. If you create an attribute that returns a reference type, the caller can access the public members of
Do you want to know how many objects are created by the specified class? Using static to implement object counters
/**
* Implementation Statistics class object number
* @author: Wolfofsiberian */public
class countobject{public
static int
In the previous article, I introduced to you a control of the number of objects to implement the way (see link: http://blog.csdn.net/wolfofsiberian/article/details/39856367) but given that This program is not complete enough to achieve. Because, we
C + + In contrast to the C language, greatly enhanced support for strings, in addition to the use of C-style strings, you can also use the built-in data type string,string class processing string because the function of the encapsulation is
Summary: 1. The first benefit of the internal class is to hide the operations you don't want others to know, that is, encapsulation.2. An internal class object can access the content of its external class object, and even include private variables!
10.1 create an internal classIf you want to create an internal class object from any location other than the external class non-static method, you must specify the object type: outerclassname. innerclassname.
10.2 link to external class
When an
Public interface contents { Int value (); } Public interface destination { String readlabel (); } Public class goods { Private class content implements contents { Private int I = 11; Public int value (){ Return I; } } Protected class
Java internal class (InnerClass) ---- non-static internal class, static internal class, local internal class, anonymous internal classMany people are not familiar with the java underwear Class. In fact, similar concepts also exist in c ++, that is,
During the loading phase of the class file, the virtual machine stores the class information in the method area data structure and generates a class object in the Java heap as the entry for the class information.If you write a piece of code: Object
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
From: http://blog.chinaitlab.com/html/02/1720702-156067.html
Internal class: the definition of an internal class is defined in another internal class.The reason is:1. An internal class object can access the implementation of the object created for
Mentioned Java internal class (
Inner class) Maybe many people are not familiar with it. In fact, similar concepts also exist in C ++, that is, nested classes (
Nested class). The differences and connections between the two are compared in the
(i) Construction and destruction of objects (object construction and destruction)In general, we will place the object as far as possible near the section of the program that uses it, which can save unnecessary objects from generating operations and
Note One: You can use the member methods of the external class as well as the member variables in the inner class.
It is well known that when defining a member method or a member variable, you can add some modifiers to it to prevent access to other
Package static_neibulei_yu_fei_static;Public class Static_neibulei_Test {Private static int eye = 2;Private String name;Static_neibulei_Test (){}Static_neibulei_Test (String name ){This. name = name;}Class Nei {Private int numNei = 0;// Private
The order of Java class initialization is often confusing, and now this article tries to give the JVM an explanation by experimenting with the initialization order of classes in the Java non-inheritance and inheritance relationships from the JVM's
Many people may not be familiar with the inner class mentioned in Java. In fact, similar concepts also exist in C ++, that is, nested class ), the differences and connections between the two are compared in the following section. On the surface, the
1. Apart from static data members, data members cannot be explicitly initialized in the class body.
For example:Class first {Int Memi = 0; // ErrorDouble memd = 0.0; // Error};
Class data members are initialized through the class constructor.
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.