PM ranking code-Android [top ranking] and pm ranking android
82 PM coding-Android [top experts ranking]
This is the seventh article in the Android series and the last article about the Java language. After this article, we will officially start learning about Android. However, you still need to learn this article well and lay a good foundation for Java, so learning Android will get twice the result with half the effort.
Not long ago, the public account article had broken through0.2 million wordsNow, I'm very happy.80I have published many articles. There are still many articles in the plan. I hope I can keep writing it. Without your support, I cannot have the power code so many words. Next, we will not publish the Android tutorial all the time. Instead, we will post an article interspersed and hope you will continue to support it!
The main content of this article is as follows. I will continue to use my method to tell you about the original boring programming.Ranking of the top martial arts experts of Jin YongOh, please be patient .. ~) Else
1 abstract class
2 Interface
3 packages and Access Permissions
[Abstract class]
Java can create a classParent classThis type is calledAbstract class. The abstract class is very strange. At first glance, I don't know what it is. Because it only declares the method, but does not implement...
Note:
1Abstract classAndAbstract MethodRequiredAbstractKeyword Declaration
2 abstract classCannot be instantiated directlyThat is, it cannot be used directly.New KeywordGenerate objects
3. abstract MethodYou only need to declare and do not need to implement
4. The subclass of an abstract class must override all abstract methods before it can be instantiated. Otherwise, this subclass is still an abstract class.
5. Note that methods in abstract classes can be abstract methods (with the keyword abstract added) or general methods (without abstract)
After in-depth analysis and analogy, I found that the abstract class still has a certain effect. Abstract classes are likeModule (mu) BoardIt allows the designer to create and modify a new class based on its format.
For example, you will understand:
Jin Yong's martial arts world is deeply loved by generations of Chinese people. It is well known for its outstanding works, such as "tianlong", "Shoot sculpture", "God sculpture", and "Yi Tian. There are so many heroes in these works, and Chinese people like to arrange seats. Well, I will take this opportunity today to arrange for you, pat...
(1) top ranking
Now that I want to make a ranking, I must first make a standard entry into the ranking. In other words, I want to create a top-notch ranking template. So, Let's do it.
The template of the top experts needs to know which martial school the hero belongs, and then the various sects will select the first one in their eyes (Portal instantiation object). First, we should abstract a ranking template of martial arts schools. The following information may be contained:Hero's name,The hero is from the Jin Yong novel.And have himKung fu description, Like the following:
Abstract martial arts school {name of the warrior; the source of the warrior; Peerless martial arts of the warrior; Description of the Warrior (){}}
This is because the hero who applied to join the rankings has not yet determined who the team is and does not know which team it belongs to. Therefore, the "Description of the hero's martial arts" method is as follows:Empty, abstractYou must wait for the specific applicant to confirm the content.
The programming language is as follows:
Abstract class WuLinMenPai {String DaXiaName; // Daxia name String FromWhere; // Daxia source String JueShiKongFu; // The peerless martial arts Description of Daxia public abstract String Description (); // application description}
(2) heroes who are eager to apply for the rankings
Since I heard that there is a top-ranking application activity, various sects in the Jin Yong series are eager to try, and they have provided their own application templates. Let's take two examples:
Shaolin School {heroes applied by Shaolin School (name, source, peerless martial arts) {warrior name = Name; warrior source = source; hero's peerless martial arts = peerless martial arts ;} description of the applicant () {"Hero:" + name + "Source:" + Source + "my peerless martial arts:" + peerless martial arts ;}} -------------------- Xiaoyao school {name, source, and peerless martial arts applied by Xiaoyao school {name = Name of the hero; Source = source; Peerless martial arts = peerless martial arts ;} description of the applicant () {"Hero:" + name + "Source:" + Source + "my peerless martial arts Description:" + peerless martial arts ;}
The program version is like this. For more information, see:
ShaoLin School ShaoLin extends WuLinMenPai {public ShaoLin (String DaXiaName, String from, String JueShiKongFu) {DaXiaName = name; FromWhere = from; JueShiKongFu = kongfu;} public String Description () {return ":" + DaXiaName + ", source:" + FromWhere + "my peerless magic" + JueShiKongFu ;}} xiaoYao school class XiaoYao extends WuLinMenPai {public XiaoYao (String DaXiaName, String from, String JueShiKongFu) {DaXiaName = name; FromWhere = from; JueShiKongFu = kongfu;} public String Description () {return ":" + DaXiaName + "Source:" + FromWhere + "my peerless power Description:" + JueShiKongFu ;}}
Then, all the sects provided the criteria for judging the heroes in their own sects. As a result, many sects enthusiastically submitted their applications.Glen martial arts expert Science Review CommitteeEvaluation,
Shortlisted list of top experts {Shaolin DMP = heroes applied by Shaolin School ("Damo", "I'm from many places in the Jin Yong series. I will mention me when I have some places in Shaolin ", "jiuyang shangong", "yijinjing", and "Shaolin 72 stunt"); Xiaoyao school's old father = the hero applied by Xiaoyao school ("Xiaoyao old ancestor", "From tianlong Babu ", "bei Ming shangong", "Xiao wuxianggong", "lingbo weizibu", "ba Huang Liuhe Wei Zun", "Tianshan Liuyang zhangzhang", etc. At the same time, he is also proficient in medicine and Qimen Yijia, still handsome... "); Publicize the description of Damo (); publicize the Second Speed of the happy old ancestor ();} ----------- program version class JueDingGaoShouRuWei {public static void main (String [] args) {ShaoLin DaMo = new ShaoLin ("DaMo", "I'm from many places in the Jin Yong series. I will mention me when I have some places in ShaoLin ", "9 Yang shagong", "Yi Jinjing", "Shaolin 72 stunt", kaishan ancestor of Chinese Buddhism "); XiaoYao XiaoYaoLaoZu = new XiaoYao (" XiaoYao laozu ", "From tianlong Babu", "bei Ming shangong", "Xiao wuxianggong", "Ling Bo Microstep", "ba Huang Liuhe Wei Zun", and "Tianshan Liuyang zhangzhang, at the same time, he is also proficient in medicine, and is still handsome... ");} System. out. println (DaMo. description (); System. out. println (XiaoYaoLaoZu. description ();} --------------- the output result is as follows. Then, add some private rankings that I personally think are top martial arts experts: (ranking 1st) hero: Damo Source: I am from many places in the Jin Yong series, where I am from Shaolin, I will mention my peerless martial arts descriptions: "9 Yang Magic", "Yi Jinjing", and "Shaolin 72 stunt". kaishan ancestor of Chinese Buddhism (ranking 2nd) Xia: Xiaoyao ancestor Source: my peerless martial arts from tianlong Babu: BEI Ming shangong, Xiao wuxianggong, Ling Bo weibu, BA Huang Liuhe Wei weizwon, and Tianshan Liuyang zhangzhang. He is also proficient in medicine and Qimen Yijia, still handsome... (Ranking 3rd) hero: Huang Yi Source: Legend of the legend of the Condor Hero My peerless martial arts Description: Author of the martial arts premium classics "9 Yin Zhenjing" (ranking 4th) hero: lone man for defeat Source: my peerless martial arts descriptions: "The solitary nine swords", the sword of life to the environment, the sword has no intention, the soft sword impermanence, the heavy sword without front, the wooden sword without lag, no sword without strokes... (Ranking 5th) hero: Former eunuch Source: swordsman my peerless martial arts Description: the original author of the sunflower collection, which has never been defeated in the East and has been practicing the sunflower collection for only 12 years. it's already amazing. I can't imagine how amazing he is...
[Interface]
Before we introduced the class, we said that Java isNot SupportedMulti-inheritance, that is, the sub-class has only one parent class in Java, which is similar to the martial arts world,One apprentice can have only one master.
However, sometimes the reality is very complicated. You can only have one master, but you want to learn more martial arts. Java introduces the interface concept to solve this problem.
Interface (Interface) Is a mechanism for implementing multi-inheritance in Java and the most important part in Java design. Note:
1 The interface is similar to an abstract class,The data member in the interface must be initialized.And are constants. For example, the interface defines an age, int age = 25, and the initial value must be assigned to age.
2. All methods in the interface must be declared as abstract, that is, the interface cannot have both abstract methods and general methods like abstract classes.
3 because all the methods in the interface are abstract methods, the abstract keyword can be omitted. The member attributes in the interface are constants, so the final keyword can also be omitted. However, don't forget to add abstract and final to them...
Similarly, you can easily understand the following:
(1) Qiao Feng, the most popular hero in the Jin Yong Series
Many people likeQiao FengDaxia, using him as a chestnut to help everyone understand the concept of interfaces, I think it is better.
We know that Qiao Feng was the first master of Xuan Kuai from the apprentice Shaolin: Master Xuan Kuai (Shaolin) {kung fu 1 Dragon Claw hand (one of Shaolin's skills ); martial arts 2 drop the magic Palm (one of Shaolin's skills); Martial Arts kung fu description () {our Shaolin signboard martial arts are "Dragon Claw hand" and "Drop the magic Palm";} we know, qiao Feng later became a helper of the gang: Kung Fu Wang jiantong (former helper of the gang) {kung fu 1 = ""; Martial Arts 2 = ""; Martial Arts kung fu description () {the martial arts of our gang's signboard are the "Drop the Dragon 18 Palm" and the "Dog Hitting stick method ";}}
Therefore, Qiao Feng's martial arts is actually a collection of the essence of Shaolin and Yi Gang, but his real master is the Xuan bitter master he started to worship, and later he went to Yi Gang, I learned martial arts again, but this is not a real apprentice,Another contractual relationshipIn martial arts, such a relationship is allowed, and will be used in JavaInterface)Now:
Master Xuan Ku is the parent class XuanKu {String Kongfu1 = "Longclaw hand"; // String Kongfu2 = "", one of Shaolin's unique skills "; // One of Shaolin's skills} Wang jiantong is the interface wangjiw.g {String Kongfu3 = ""; String Kongfu4 = "Description"; public void Description (); // Description about martial arts} Qiao Feng inherits Xuan ku and also inherits Wang jiantong class QiaoFeng extends XuanKu implements WangJianTong {public void Description () {System. out. println ("Qiao fenghui kung fu is" + Kongfu1 + "" + Kongfu2 + "" + Kongfu3 + "" + Kongfu4 );}} class Test {public static void main (String [] args) {QiaoFeng = new QiaoFeng (); QiaoFeng. description () ;}} the output result is: Qiao fenghui's effort is to drop the magic palm of the Dragon's claw hand and drop the dragon's 18-footed dog's stick.
[Package and access permission]
I have mentioned the Object-Oriented Knowledge Point in the previous section, but now I want to talk about some special[Package]Concept.
A package is a special property of a class,A package is used to manage a large number of class files and allows others to access class members.. The package can be understood as a larger, management class (a bit of logging )...
For example, you will understand:
In the world of martial arts, martial arts is also very large, and all birds are owned by Lin Zi. It is possible that the names of the two sects are the same. If this happens when the world's first martial arts conference is held, it's easy to crash. When you see two sects with the same name, I don't know what you think.
For example, the great Shaolin has been split into several groups. If they say they are Shaolin's, they will easily lead to confusion and make the rivers and lakes feel fun, shaolin in the north called itself North Shaolin, and Shaolin in the south called itself South Shaolin.
When you use multiple classes or interfaces,Measure used to avoid duplicate names, UsePackageKeyword: declare a package and use the package to distinguish classes and interfaces with the same name.
School Shaolin (North) {external publicity () {I am Shaolin;} school Shaolin (South) {external publicity () {I am Shaolin;} at the Wulin conference, in this case, Duang will crash... If a region (package keyword) is added in front, you can separate the two sects (classes): north of the region; Shaolin martial arts {external publicity () {I am Shaolin ;}} south of the area; Martial Shaolin {external publicity () {I am Shaolin;} -------------- the code is like this: package. north. java; // declare the region class ShaoLin {public String talk () {return "I am ShaoLin" ;}} package. south. java; // declare the region class ShaoLin {public String talk () {return "I am ShaoLin School" ;}}. In this way, the two ShaoLin schools can be distinguished. Isn't it amazing ??
Notes
1. keywords are used to declare a packagePackageKeywords
2. keywords are used for different packages.Import(Meaning import)
(Border of Lili)
Okay. I have finished speaking Java through several articles. Let's review it:
78 PM coding-Android [one-hour learning of Java]: This article describes the basic Java syntax.
79 PM coding-Android [Martial Arts: object-oriented Basics]: This article briefly describes process-oriented and object-oriented, and introduces an important knowledge of object-oriented classes and objects.
Android with 80 PM coding [Martial Arts encapsulation, inheritance, and polymorphism]: This article focuses on three object-oriented features-encapsulation, inheritance, and polymorphism.
82 PM coding-Android [top ranking]: This article describes abstract classes, very important interfaces, and package-related knowledge.
The basic Java knowledge required for Android development has almost been completed. There are also some fragmented knowledge that is useful, but you can add this knowledge when learning to develop Android, they are:
Anonymous object, constructor, exception handling, keyword (this, static, super, final), String, StringBuffer, etc.
Learning and complementing are ideal. ^ _ Oh, my mouth is smiling... It should be the purple sauce ^_^...
The next article will officially start to hook up with Android. Thank you for your support!
Who is Glen?
I am a 0-year-old product manager from Sun Yat-sen University, commonly known as PM0. Coming out of campus, sharing experiences, products, Data, Reading Notes, and interconnected Rivers and Lakes. May you and I grow together on the road to products!
From Media Alliance after 90
JiGlen
The post-90s Media Alliance is an organization that brings together new Internet practitioners such as BAT. It is currently operated in groups. Here are some great gods who are eager to create and share their own product success stories and ideas, exchange our experience in media operation and creation. Everyone in the company is a product manager and an Internet er morning reading class.
If you are interested in joining us, you can follow my public account JiGlen to describe your public account or other blogs. After the review is passed, you will be pulled into the group.