10.23 homework: Liu huihui, 10.23 homework: Liu huihui

Source: Internet
Author: User

10.23 homework: Liu huihui, 10.23 homework: Liu huihui

Package cn. person. www; public class Prson {public int id; public String name; public int age; public String city; public String introduce () {return "I am" + id +, name: "+ name +", this year "+ age +" years old, from "+ city;} public person (int id, String name, int age, String city) {this. id = id; // this keyword, which indicates the current object. this indicates a call of the current object. name = name; this. age = age; this. city = city ;}}

  

Package cn. person. www; public class Demoperson {public static void main (String [] args) {// TODO Auto-generated method stub person p1 = new person (001, "Liu Bei", 40, "Beijing"); person p2 = new person (002, "Guan Yu", 37, "Beijing"); person p3 = new person (003, "Zhang Fei", 45, "Beijing"); person p4 = new person (004, "Zhuge Liang", 25, "Beijing"); System. out. println (p1.introduce (); System. out. println (p2.introduce (); System. out. println (p3.introduce (); System. out. println (p4.introduce ());}}

  

Related Article

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.