Java from basics to advanced learning---class authoring and document gazing.

Source: Internet
Author: User

Java has learned before, the basics are not forgotten, and these high-level languages are too similar, so those data types, or the loop control flow, as well as standard equipment, and so on are just skip it.

Just a few important concepts will be interspersed in the introduction of the article.

So, these articles are suitable for those who have a certain level of advanced object-oriented language basis for reading.

We first write a student class. Its main requirements to be familiar with the content is:

Understanding and understanding of class constructors (construction methods).

about how the method was written.

About the use of member variables & this,

With this familiarity, we are able to write this class according to the following class diagram.

The constructor's parameters are name, gender, and number of studies.

Class diagrams such as the following:

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc3vvb2w=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">


I wrote the following code for the reference:

I've written all the attributes into the private type, because the data can write a set and get method .....


/*** description:* <br> blog:<a href = "http://suool.net" target= "Blnak" > Suool ' s Blog </a> * <br> Copyright (c), 2014-2015, Suool * <br> This program are writeen by Crazy java.* <br> program Name:student.ja VA * @author: suool* @version: 1.0.0*/public class student{///private variable privately string stu_name;private string Stu_sex;p Rivat E long stu_id;p rivate int stu_age;/*** Student Construction method * @param name construct student instance name * @param sex structure Student instance gender * @param Id Construction Student Case study Number, the beginning number is not zero */public student (string name, String sex, long Id) {this. Stu_name = Name;this. Stu_sex = sex; stu_id = Id; }/*** Set Age method * @param age to set the student's ages */public void Setage (int.) {this. Stu_age = age; System.out.println ("You set the age of the student" + this. Stu_name + ' is ' + this. Stu_age);} /*** gets the student number of the specified pupil * @return Returns the long integer number value */public long GetID () {System.out.println ("You get the ID of the student" + this. Stu_name + ' is ' + this. Stu_age); return this. stu_id;} /*** Main method * @param args command line */public Static VOID Main (string[] args) {//Constructs student object Student Tom = new Student ("Tom", "Boy", 122511042); student Jelly = new Student ("Jelly", "Girl", 122511043); Tom.setage (20); System.out.println (Tom.getid ());}}

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc3vvb2w=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">

The resulting Javadoc such as the following.

Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc3vvb2w=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/southeast ">



Next, in the next section, write a small game, command-line version of the AI-free Gobang.

It's actually the practice of arrays and standard input and output.


"If you don't make the time-to-work on creating the life you want, you ' re eventually going to being forced to spend a lot of Time dealing with a life you don ' t want. "--kevin Ngo

Java from basics to advanced learning---class authoring and document gazing.

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.