zoukankan      html  css  js  c++  java
  • 【每日日报】第六天

    1 今天写了学生类的程序

      题目要求:

     程序源代码:

    package Student;
    import java.util.Scanner;
    public class Student {
     public static void main(String[] args){
      char[] s1 = {'2','0','1','9','0','3','2','7'};
      char[] s2 = {'d','o','u','b','l','e','b','e','s','t'};
         Student stu1 = new Student(s1,s2);
         stu1.setAge(21);
         stu1.show();
         Student stu2 = new Student(stu1);
        
         Scanner input = new Scanner(System.in);
         String s = input.nextLine();
         s1 = s.toCharArray();
        
         s = input.nextLine();
            s2 = s.toCharArray();
           
         stu2.setNo(s1);
         stu2.setName(s2);
         stu2.show();
         input.close();
     }
     static int sum = 0;
       Student(char[] NO,char[] NAME){
         int i=0;
         no = NO;
         name = NAME;
         sum++;
         System.out.println("Constructor run");
         System.out.println("NumTotal:"+sum);
        }
        Student(char[] NO,char[] NAME,int AGE){
            no = NO;
            name = NAME;
            age = AGE;
         sum++;
         System.out.println("Constructor run");
         System.out.println("NumTotal:"+sum);
        }
        Student(Student S){
         no = S.no;
            name =S.name;
          age = S.age;
          sum++;
          System.out.println("CopyConstructor run");
          System.out.println("NumTotal:"+sum);
        }
        void setNo(char[] NO){no = NO;}
        char[] getNo(){return no;}
        void setName(char[] NAME){name = NAME;}
        char[] getName(){return name;}
        void setAge(int AGE){age = AGE;}
        int getAge(){return age;}
        void show(){
         System.out.print("No:");
         System.out.print(getNo());
         System.out.print(",Name:");
         System.out.print(getName());
         System.out.println(",Age:"+age);
        }
        char[] no;
        char[] name;
        int age;
    }
     
     运行截图:

     2 今天知道了在java语言中没有指针的定义,但是在传参的时候可以传数组

    3 明天继续写题

  • 相关阅读:
    HDU 2236 无题Ⅱ
    Golden Tiger Claw(二分图)
    HDU 5969 最大的位或 (思维,贪心)
    HDU 3686 Traffic Real Time Query System (图论)
    SCOI 2016 萌萌哒
    Spring Boot支持控制台Banner定制
    构建第一个Spring Boot程序
    Spring Boot重要模块
    Java fastjson JSON和String互相转换
    BCompare 4 Windows激活方法【试用期30天重置】
  • 原文地址:https://www.cnblogs.com/linmob/p/13296685.html
Copyright © 2011-2022 走看看