zoukankan      html  css  js  c++  java
  • 20200723 千锤百炼软工人第十八天

    今天完成了昨天的程序

    改完了那个程序

    在此附上代码和截图

    Stundent类的代码

    package a20200723;
    public class Student {
     private String name;
     private String no;
     private int age;
     private static int sum=0;
     public String getNo() {
      return no;
     }
     public String getName() {
      return name;
     }
     public int getAge() {
      return age;
     }
     public void setNo(String no) {
      this.no = no;
     }
     public void setName(String name) {
      this.name = name;
     }
     public void setAge(int age) {
      this.age = age;
     }
     public Student() {
      this.no=null;
      this.name=null;
      this.age=0;
      sum=sum+1;
      System.out.print("Constructor run ");
      System.out.print("NumTotal:"+sum+" ");
     }
     public Student(String no,String name, int age) {
      this.name = name;
      this.age = age;
      sum=sum+1;
      System.out.print("Constructor run ");
      System.out.print("NumTotal:"+sum+" ");
     }
     public void show(){
      System.out.println("我叫"+name+",我今年"+age+"岁 ");
     }
     pubhli'zc v'yoizd finalize() {
      sum=sum-1;
      System.out.print("Destructor run ");
      System.out.print("NumTotal:"+sum+" ");
     }
    }
     
    主函数代码
      package a20200723;
    import a20200723.Student;
    public class main {
     public static void main(String[] args)
     {
     String s1="20190327";
       String s2="doublebest";
       Student stu1=new Student(s1,s2,0);
       stu1.setAge(21);
       stu1.show();
       Student stu2=new Student();
       stu2=stu1;
       stu2.setNo(s1);
       stu2.setName(s2);
       stu2.show();
       stu1=null;
       stu2=null;
       System.gc();

    }
    截图
        
  • 相关阅读:
    Spring经典视频教程大集合
    使用jsonlib进行Java和JSON之间的转换
    c:import Unable to get RequestDispatcher for Context
    打开IE都会弹出欢迎界面“欢迎使用Internet Explorer 8”
    Struts2 标签 用法示例 (
    as3相关的frameworks
    as相关的框架引擎应用集合
    init
    XNA框架基础——疑难解答
    XNA框架基础——XNA的注意事项
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/13368092.html
Copyright © 2011-2022 走看看