Java Object-oriented

Source: Internet
Author: User

1 Java Object-oriented
SVG vector graph
node. js

Java
C
Object-c (Apple bottom) Swift
C++
C#
JavaScript (front desk)
Ruby


How object-oriented is created

1 using the new operator

2-character variable using the new operator

Creating objects

var user = new Object ();
User.Name = ' Programming prodigal ';
User.age = 22;
user.address = ' Chengdu, Sichuan ';

This makes it simple and intuitive to create objects, but the disadvantage is that when you need to create multiple objects,

This is not an appropriate method of creation (memory impact) in order to solve this problem we have a factory model

Factory mode: Resolves an issue where instantiating objects produce large amounts of duplicate code.

To create a new instance of the user object, use the new operator to build the instance object in this way, which takes the following 4 steps:
1. Create a new object;
2. Set the scope of the constructor to the new object (hence this new object that this is pointing to).
3. Execute the code within the constructor (add attributes to the new object);
4. Returns the new object.

3 constructors (treated as classes)

Class is not an object, just a representation of this type of extraction

Note: 1 The first letter of the reputation structure is capitalized.

2 When a function is called as a normal function, the pointer to the this object inside the function is actually pointing to the window global object.

In the case of the new keyword, this is the object.

3.1 Disadvantages of constructors

Method calls repeatedly, wasting memory

4 prototype prototype--object properties (object) pointers

5 Recommended constructors + prototype prototypes

6 What is a prototype?

The prototype object is actually an instance object of the constructor, and there is no intrinsic difference from the normal instance object.

You can include shared properties or methods for all instances of a specific type. The attribute value of this prototype is a

Object (a collection of attributes), the default is only a property called constructor, pointing to the function itself.

Java Object-oriented

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: info-contact@alibabacloud.com 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.