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 明天继续写题

  • 相关阅读:
    目前阻碍大数据成功的常见问题有哪些
    YII2 的授权(Authorization)
    CCBPM工作流引擎的消息机制与设计
    日志框架实现实时改动,实时生效,详细框架思路(2)
    manacher hihoCoder1032 最长回文子串
    C#.NEt-GDI+中的Pen測试
    Unity3D游戏开发最佳实践20技巧(一)
    Android init.rc文件浅析
    OBIEE开发手冊
    Android Jni层 创建 linux socket 出错问题解决
  • 原文地址:https://www.cnblogs.com/linmob/p/13296685.html
Copyright © 2011-2022 走看看