Java is an object-oriented language, and object-oriented programming mainly embodies the inheritance, encapsulation, polymorphism three characteristics, then what is an object?
In fact, translation has been done very well, as long as the understanding of the Chinese character-like.
"Yi": In the days of the elephant.
"Sparse" is called sowing like stars also.
"Yi": The elephant Also, like this person also.
"Shu" is like the shape of this thing.
What is "elephant"? Like, the shape of all things, the shape of all things, the situation of all things, the phase of everything.
Heaven and earth all things are one by one, entity, however, although this entity exists, if nobody can see it, no one consciousness can perceive it, it is equal to not exist, there is no meaning, there is no value. Therefore, the elephant does not really mean that the actual existence, all the pictographic is only what we human beings see, feel, what we observe, and what everyone sees is not really the same, everything is changing, there is no real eternal entity; it is difficult for a man to truly and thoroughly understand the true nature of a thing, as Buddhism says: "The color is empty, Empty is color, color is not empty, air is not also color "," all have a law, such as fleeting dream, such as dew also such as electricity, should be applied. " (This philosophical question can also refer to the observer pattern of quantum science)
The abstract, ha, what is abstract? Extracting the "elephant" of a being is abstract. It is a concept, a person's understanding of things, a collection of things, which can represent that thing, although it cannot be expressed in a real sense. Therefore, abstract, the actual meaning is to obtain a thing of the "elephant" process, because the process is not understanding, so the abstract also has a difficult to understand, very unfamiliar meaning.
Programming language is the computer World language, the equivalent of the real world rules, the person who really mastered the rules can become the creator. Of course, the computer world is part of our real world, and the creator of the computer World is a programmer, and one thing created by the creator can be described as "object". Similarly, this can also be called with other words, do not persist, Lao Tzu also said: "Dao can road, non-Heng Dao also, name can name, non-constant name also", "I do not know its name, Strong said that the word '", all the name is just the description of things, as long as a description is not that thing.
So what exactly is "creation"? differs in different programming languages. In Java, the "creation" process is an instantiation of an object, and the code behaves as follows:
new 类名();
So the question comes out again, in programming languages, what is a class?
A class is a collection of properties and functions that you want to describe things. Of course, the class as a existence, whether it is the concept of existence, or as the bearer of specific code of the existence of the file, or other forms, which is of course an object.
As a conceptual existence, a class is nothing more than a set of "elephants" that describe something in a programming language, not really physical, unlike a book, a chair, but a human consciousness.
As the bearer code exists, it will have a "body", its body is a computer on a xxx.java or xxx.cpp such files, "After the gut", you can see "Public xxx" and other organs or cells.
So what is the specific form of code creation? Written in the Java language, choose a character that does not exist in the real world-the Monkey king, as the object of the description. The code is as follows:
Public class Monkey King { PrivateString name;//Name Private DoubleHeight//height, goku height is variable Private DoubleWeight//Weight, Goku's weight is also variable Private Static FinalString racist ="Ling Mss monkey";//Race, Goku is the Spirit Mss Monkey, still in the womb is determined. As the author is dead, it cannot be changed. Change is the novel of the Doujinshi. /** * Set the name, Bodhi Lao zu Take the * * Public void SetName(String name) { This. name = name; }/** * Get the name * * PublicStringGetName(){returnName }/** * Set Height * / Public void setheight(DoubleHeight) { This. height = height; }/** * Get height * / Public Double getheight(){returnHeight }/** * Set weight * * Public void Setweight(DoubleWeight) { This. Weight = weight; }/** * Gaining weight * * Public Double Getweight(){returnWeight }/** * Get the name of the race * * PublicStringgetrecist(){returnRacist; } }
After the launch of the Journey to the Monkey:
public class journey to the monkey {public static void main (string[] args) throws Interruptedexception {System. out. println("Journey to the Monkey" begins \ n ");Thread. Sleep( +);System. out. println("... Nu wa Mending the end of the day ... Leave a piece of huaguoshan in the stone.);Thread. Sleep( +);System. out. println("multicolored stone absorbs the essence of the sun and the moon every day ... \ n");Thread. Sleep( the);//The multicolored stone continues to absorbSystem. out. println("After n Dovanne, finally multicolored stone inside pregnant fairy fetus ... \ n");Thread. Sleep( +);Monkey King WuKong = new Monkey King ();//Create ObjectWuKong. SetHeight(1.6);//goku about 1.6 meters highWuKong. Setweight( -);//goku about 70 pounds, though it is stoneSystem. out. println("Breaking, Huaguoshan day Stone Monkey was born, the eye shot Golden, straight to the cow, Jade Emperor life clairvoyance ears search ... \ n");Thread. Sleep( +);System. out. println("The Stone Monkey Race:"+wukong. Getrecist());System. out. println("clairvoyance Ears Report: The height of a stone monkey is probably"+wukong. GetHeight());System. out. println("The stone monkey weighs roughly:"+wukong. Getweight());Thread. Sleep( +);System. out. println("\ n ... Stone Monkey when the Monkey King, because of the sense of birth and death, sea all over the real teacher ... \ n ");Thread. Sleep( the);//The Stone monkeys continue to look for ...System. out. println("After a few years ... To the "Lingtai Mountain, oblique month Samsung Hole" ... The old ancestor of Bodhi);WuKong. SetName("Monkey King");System. out. println("Bodhi old fathers named Stone Monkeys:"+wukong. GetName());Thread. Sleep( +);System. out. println("\ n ... Wukong to give spells ... ");Thread. Sleep( +);System. out. println("Wu-empty cast the law of the heavens and the land ... \ n");WuKong. SetHeight(999);WuKong. Setweight(999);Thread. Sleep( +);System. out. println("So goku height:"+wukong. GetHeight());System. out. println("Weight:"+wukong. Getweight());System. out. println("\ n ..." ....... ..... ..... ... "......., .............);System. out. println("... The beginning of the great cause ... ");Thread. Sleep( the);System. out. println("... Merit perfection ... ");System. out. println("--the journey to the end--");}}
Operating effect:
"Journey to the Monkey" begins.
...... Nu wa Mending the end of the day ... Leave a piece of stone in Huaguoshan
Multicolored stone absorbs the essence of sun and moon every day ...
After n Dovanne, finally multicolored stone inside pregnant fairy fetus ...
Breaking, Huaguoshan day production Stone Monkey was born, the eye shot Golden, straight to the cow, Jade Emperor life clairvoyance ears search ...
Stone Monkey race: Ling Mss Monkey
Clairvoyance Ears report: The stone Monkey is about 1.6 tall.
Stone monkey weight approx.: 70.0
...... Stone Monkey when the Monkey King, because of the sense of birth and death, sailing all over the search for real teacher ...
After a few years ... To the "Lingtai Mountain, oblique month Samsung Hole" ... The old ancestor of Bodhi
Bodhi old ancestor named Stone Monkey: Monkey King
...... Wukong to grant spells ...
Wu-empty cast the Law of Heaven and land ...
So goku height: 999.0
Weight: 999.0
................................................
...... The beginning of the great cause of pilgrimage ...
...... Merit Perfection ...
– Journey to the end –
What is an object?