• Demoperson


     1 package com.duixiangninth;
     2 
     3 import java.security.Permission;
     4 
     5 public class DemoPerson {
     6 
     7     public int id;
     8     public String name;
     9     public int age;
    10     public String city;
    11     public String introduce() {
    12             return "My id=" + id + ", name=" + name + ", age=" + age + ", city=" + city ;
    13         }  
    14      public DemoPerson() {
    15             
    16         }
    17         //有参数构造
    18         public DemoPerson(int id,String name,int age,String city) {//形式参数,接收实参
    19             this.id=id; //this关键字,表达的含义是当前对象 .表示当前对象的某个调用
    20             this.name=name;
    21             this.age=age;
    22             this.city=city;
    23         }
    24 
    25     public static void main(String[] args) {
    26         /*DemoPerson p1=new DemoPerson(110001,"刘备",43,"北京");//这叫实际参数,实参
    27         DemoPerson p2=new DemoPerson(110002,"关羽",35,"上海");
    28         DemoPerson p3=new DemoPerson(110003,"张飞",25,"广州");
    29         DemoPerson p4=new DemoPerson(110004,"诸葛亮",20,"茅庐");
    30         p1.setName("刘贝贝");
    31         shuchu(p1.getName());
    32         shuchu(p2.getName());
    33         shuchu(p3.getName());
    34         shuchu(p4.getName());*/
    35         // TODO Auto-generated method stub
    36         DemoPerson p1=new DemoPerson();
    37         DemoPerson p2=new DemoPerson();
    38         DemoPerson p3=new DemoPerson();
    39         DemoPerson p4=new DemoPerson();
    40         p1.id=110001;
    41         p1.name="刘备";
    42         p1.age=43;
    43         p1.city="蜀国";
    44         p2.id=110002;
    45         p2.name="关羽";
    46         p2.age=35;
    47         p2.city="蜀国";
    48         p3.id=110003;
    49         p3.name="张飞";
    50         p3.age=32;
    51         p3.city="蜀国";
    52         p4.id=110004;
    53         p4.name="诸葛亮";
    54         p4.age=25;
    55         p4.city="蜀国";
    56         System.out.println(p1.introduce());
    57         System.out.println(p2.introduce());
    58         System.out.println(p3.introduce());
    59         System.out.println(p4.introduce());
    60         
    61     }
    62     /* private String getName() {
    63         // TODO Auto-generated method stub
    64         return null;
    65     }
    66     private void setName(String string) {
    67         // TODO Auto-generated method stub
    68         
    69     }*/
    70     public static void shuchu(String what) {
    71             System.out.println(what);
    72      }
    73 
    74 }

    This moment will nap, you will have a dream; but this moment study, you will interpret a dream.
  • 相关阅读:
    自己编译GCC(compile gcc from source)
    sphinx PDF 中文
    rst2pdf 中文
    Pandoc PDF 中文
    Linux XMind
    asp.net 邮件发送类
    asp.net 音乐播放器
    使用X-UA-Compatible来设置IE浏览器兼容模式
    asp.net(c#)网页跳转七种方法小结
    C#中HashTable的用法
  • 原文地址:https://www.cnblogs.com/mawenqi-barry/p/7736244.html
Copyright © 2020-2023  润新知