Home > Back-end >  Java have great god for help
Java have great god for help

Time:09-22

CodePudding user response:

 
Package leetcode;

/* *
* @ the ClassName: Studeng
* @ Description: TODO
* @ author: MZB
* @ date: on May 25, 2020 morning 10:12:52
*/
Public class Student {
Private Integer stuNO;
private Integer age;

Public Integer getStuNO () {
Return stuNO;
}
Public void setStuNO (Integer stuNO) {
Enclosing stuNO=stuNO;
}
Public Integer getAge () {
Return the age;
}
Public void setAge (Integer age) {
this.age=age;
}
@ Override
Public String toString () {
Return "Student [stuNO=" + stuNO + ", the age="+ age +"] ".
}
}

Package leetcode;

Import the Java. Util. Random;

/* *
* @ the ClassName: Test
* @ Description: TODO
* @ author: MZB
* @ date: on May 25, 2020 morning 10:14:00
*/
Public class Test {
Public static void main (String [] args) {
Student stu.
The Random rand=new Random ();
for(int i=1; i<=20; I++) {
Stu=new Student ();
Stu. SetStuNO (20190100 + I);
Stu. SetAge (rand. NextInt (2) + 18);
System. The out. Println (" first "+ I +" classmate student id is "+ stu. GetStuNO () +", the age is "+ stu. GetAge ());
}
}
}
  • Related