Java Basics-Object oriented

Source: Internet
Author: User

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

Object oriented

Template: Is a class, to have a template to produce objects, template is to create objects, the common things in the same template, such as Student class, then the template is written below the students common properties and methods, attributes (description) such as: Age, gender, name, etc. Method (function): Can write, read, draw, etc.

Object: There are attributes (descriptions) and methods (functions), objects are things in our real life, whether real or virtual can be called objects (everything is the object).

Class: Is the template of the object
Not every object must have a template (class)
Object template naming is named after the category name

How to describe properties and behaviors:
1. What is the attribute used to represent? Variable
A variable request is called a property in a class.
2. What do you mean by behavior? Method (function)
Code can only be written in methods, so we use methods to represent the behavior of the object

Application format for the class:
Note: As long as the class name is public, the file name must match the class name.

How do I create an object?
Create an object using the New keyword
Object-oriented angle: Template generation Instance (object)
From the point of view of code: allocating memory, hosting properties, and methods.
The so-called new object is to allocate memory for the requested property method, and to register the value

Each new object allocates a single piece of memory.

Memory recycling?
As long as there are no variables pointing to the object's memory, Java is checked and recycled at irregular intervals.

Dot symbol (.): An accessor for an object's properties and behavior.
The object variable must be used.

A variable can store only a single value of one type, an array can store multiple values of one type, objects can store different types of values, and they can have their own methods. Objects are equivalent to a new data structure, variables can be customized, and methods can be customized.

Summary: Process-oriented is closer to the machine, object-oriented is to make the code closer to life. Programming is writing code commands to run machines, programming is to solve problems in life. Object-oriented is how code simulates life, how life solves code, how to write solutions, and how to bring code closer to life. A property is the description of an object, and the behavior is the function and behavior of the object. We need to use classes in the object, in the class to apply the variable called the property, the method of application in the class is called the behavior, the class is a template, we use classes to create objects, a class can create multiple objects. In terms of storage, a variable can store only one value, and an array can store multiple values, but the type of the array is made, the length is fixed, and the object can store different types of arrays and can store methods.

Java Basics-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.