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"