Java Object-oriented

Source: Internet
Author: User

I. Understanding what classes and objects are

Everything is object.

1. Attributes--Characteristics of objects (characteristics)

2, Method--the action that the object can perform (what to do)

3, the definition of the object:

An objective, visible, or tangible entity composed of attributes and methods.

4, the class is abstracted by the object, can't see also touch

5. What are the relationships between classes and objects?

The class (which is general) is the abstraction of the object, and the object (concrete) is the materialization of the class.

Second, package-packaging (to wrap up a thing, and hide the internal details as far as possible)

1.2 Forms of expression: properties and Methods

2, the role of packaging:

Hide internal implementation details to make it easy to operate

3, the package embodied in Java:

Class--All Java code is written in the class (method)

MyEclipse tools in the form of projects, encapsulation

Iii. Creating and Using objects

1. Create a syntax for a class

Access modifier Class class name {

Properties

public void Method name () {

Cyclic structure, condition judgment (if, switch)

Output statement

}

}

2. Create objects

Class Name Object name =new class name ();

Scanner input=new Scanner (system.in);

How do I invoke properties and methods?

Member variable (property name), by: Object name. property name;

Method, through: Object name. Method Name ();

Four, object-oriented

Class--noun

Properties--Adjectives

Method--Verb

1. Communication between classes (Access): An object in a class that is new to another class, through the name of the object. The member name of the class

Members of the class: attributes (member variables), methods (member methods)

2. Advantages:

Information encapsulation and hiding,

Improve program security, reusability, maintainability

Step 1: Write the Class (properties, Methods)

property is not assigned a value in this class

method to output the value of the property

Step 2: Create a new class with main (test Class)

Step 3:

Create an object for the class of step 1

Object name. property = value; (from console assignment)

The name of the object. Method name ();//The value of the property is output

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.