instance (instance)In object-oriented programming, "class" is called an "instance" after instantiation. "Class" is static, does not occupy process memory, and "instance" has dynamic memory. In a database, represents a collection of programs. As in Oracle, examples are database programs that support the operation of a database. Instances (instance) and objects (object) are essentially synonyms and are often used interchangeably. object represents a specific instance of a class. Objects have identities (identity) and attribute values (attributes) 2 characteristics. An instance is a concrete representation of an object, an action can be applied to an instance, and an instance can store the results of the operation in a state. Examples are used to simulate things that exist, specific, or archetypal in the real world. An object is an instance of a class, all objects are instances, but not all instances are objects. For example, an instance of an association (one in a uml relationship) is not an object, it is just an instance, a connection. Our common instances are instances of the class, and there is no difference. Instances other than instances of a class are not objects.
instantiation in object-oriented programming, the process of creating objects with classes is often referred to as instantiation. (Procedure for creating an object with a Class) format class Name Object name = new class name (); In object-oriented programming, the process of creating objects with classes is often called instantiation, and the format is as follows: Class Name Object name = new class name (parameter 1, parameter 2 ...). Parameter n); such as date date=new date (), an object that creates a date with a date class, is called an instantiation of the object. In most languages, instantiating an object is to open up memory space for an object, or to use the new constructor name () directly to create a temporary object without declaring it. Example: Java
public class a{public
static void Main (string[] args) {
b = new B ();//instantiating
b.print ();
}
}
Class b{public
void print () {
System.out.println ("hello,world!");
}
Example: C #
Namespace Test
{
class A
{public
int Sub (int A)
{return
a++;
}
}
Class B
{public
void Main (string[] args)
{
int p = (new A ()). Sub (1);
System.Console.WriteLine (p);
System.Console.ReadKey ();}}