uj5u.com熱心網友回復:
package leetcode;
/**
* @ClassName: Studeng
* @Description: TODO
* @author: mzb
* @date: 2020年5月25日 上午10:12:52
*/
public class Student {
private Integer stuNO;
private Integer age;
public Integer getStuNO() {
return stuNO;
}
public void setStuNO(Integer stuNO) {
this.stuNO = stuNO;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
@Override
public String toString() {
return "Student [stuNO=" + stuNO + ", age=" + age + "]";
}
}
package leetcode;
import java.util.Random;
/**
* @ClassName: Test
* @Description: TODO
* @author: mzb
* @date: 2020年5月25日 上午10:14:00
*/
public class Test {
public static void main(String[] args) {
Student stu;
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.out.println("第"+i+"位同學的學號是"+stu.getStuNO()+",年齡是"+stu.getAge());
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/64744.html
標籤:Java相關
下一篇:登錄認證,授權
