Object-oriented "Java Basic learning"

Source: Internet
Author: User

The Java language is an object-oriented language, and personal understanding is a class-based language.
So what is object-oriented? Object-oriented, that is, developers can take everything as objects, as individuals
For example: I want to think of my computer as an object, to create a computer class
public class computer{
This creates a computer class, very simple, without any attributes, without any function of the computer class, commonly known as the Shell Computer class (own definition)
}
Created a computer class, I want the computer to have some basic properties, the computer basically have what properties? Mouse, keyboard, monitor
In that class we are going to add these attributes to the computer class.
public class computer{
Public String mouse= "Mouse";
Public String keyboard= "Keyboard";
Public String display= "display";
}
Public corresponds to the common, then we just set these properties to private
public class computer{
Private String mouse= "mouse";
Private String keyboard= "keyboard";
Private String display= "display";
}
There are some properties in the computer class, and we want to have some features in the computer class. For example, I need to use a monitor to display a message
public class computer{
Private String mouse= "mouse";
Private String keyboard= "keyboard";
Private String display= "display";
public void Displayfunction () {
SYSTEM.OUT.PRINTLN (display + ": I am the Monitor");
}
}
Now the computer class has some properties and functions, Mouse,keyboard,display, Method Displayfunction.
The object of Java is to treat the created class as an object, placing the properties and functions held by that object in the class.

Object-oriented "Java Basic learning"

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.