Java Learning (2) && some impressions

Source: Internet
Author: User

The main learning of the Java language in the concept of the parent class, subclass, Abstract, the book said by abstracting a person class, and then derive the employee and student class, while the abstract function is redefined, so that the derived class is not abstract class.

Package Abstractclasses;public class Persontest{public static void Main (string[] args) {person[] people=new person[2]; People[0]=new Employee ("Harry", 20000,1989,12,10);p eople[1]=new Student ("Ron", "Computer Science") and for (person P: People) {System.out.println (P.getname () + "," +p.getdescription ());}}}
Package Abstractclasses;public abstract class Person{public abstract string GetDescription ();p rivate string name;public Person (String N) {name=n;} Public String GetName () {return this.name;}}
Package Abstractclasses;public class Student extends Person{private string major;public Student (string n,string m) {Super (n); major=m;} Public String GetDescription () {return String.Format (' A student majors in ' +major);}}
Package Abstractclasses;import Java.util.date;import Java.util.gregoriancalendar;public class Employee extends person {Private double salary;private Date hireday;public Employee (String n,double s,int year,int Month,int day) {super (n); Salary=s; GregorianCalendar calendar=new GregorianCalendar (year,month-1,day); Hireday=calendar.gettime ();} Public Date Gethireday () {return hireday;} Public double getsalary () {return salary;} Public String GetDescription () {return String.Format ("an employee with a salary of $%.2f", salary);} public void Raisesalary (double percent) {this.salary*= (1+percent);}}

The last two days because brush a few algorithm problem, did not learn too much Java knowledge, found about "Core Java" This book look at the progress is a bit too slow, and there are many other things to do (distributed, C + +, game engine, web security, etc.), pushed off all the feeling can not improve their strength of the project, There is a year time is the intern recruitment time, the goal is to be able to enter a satisfactory company to practice, who knows, who said I can not enter the MS! Although the previous 1.5 wasted a lot of time, but the feeling learned a lot of algorithms and data structure, but also is an upgrade bar, will continue to brush the subject of ACM, after all, the algorithm this thing needs to accumulate! But I will not pay too much attention to the performance points and so on, the feeling is no use, shun its natural good, professional examination class well prepared on the line, English can not be released! Next year if I can not find a satisfactory internship, go to prepare for postgraduate examination.

Java Learning (2) && some impressions

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.