-
byte b1=4,b2=3; sout(--b1 | b2++ ^ --b1 & b1++ * b2--)
package day05.homework;
/**
* copyright(c)2021 YCKJ.ALL rights Reserved
* <p>
* 描述:
*
* @author tanyi
* @version 1.0
* @date
*/
public class H1 {
public static void main(String[] args) {
byte b1 = 4, b2 = 3;
// 3 | 3 ^ 2 & 2 * 4
// 3 | 3 ^ 2 & 8
// 0000 0010
// 0000 1000
// 0000 0000
// 0000 0011
// 0000 0011
// 0000 0011
// 0000 0011 转换为十进制为:3
System.out.println(--b1 | b2++ ^ --b1 & b1++ * b2--);
}
}
-
Student .java: id int name String StudentManager.java: students Student[] addStudent(Student) void 用动态数组的思路解决。
package day05.homework;
/**
* copyright(c)2021 YCKJ.ALL rights Reserved
* <p>
* 描述:
*
* @author tanyi
* @version 1.0
* @date
*/
public class Student {
/**
* 学生id
*/
private int id;
/**
* 学生姓名
*/
private String name;
/**
* 获取学生id
* @return 返回学生id
*/
public int getId() {
return id;
}
/**
* 设置学生id
* @param id
*/
public void setId(int id) {
this.id = id;
}
/**
* 获取学生姓名
* @return 返回学生姓名
*/
public String getName() {
return name;
}
/**
* 设置学生姓名
* @param name
*/
public void setName(String name) {
this.name = name;
}
public Student(int id, String name) {
this.id = id;
this.name = name;
}
}
package day05.homework;
import day03.homework.StudentManage;
import java.util.Arrays;
/**
* copyright(c)2021 YCKJ.ALL rights Reserved
* <p>
* 描述:
*
* @author tanyi
* @version 1.0
* @date
*/
public class StudentManager {
/**
* 存储学生的数组
*/
Student[] students;
/**
* 当前的位置
*/
int index;
/**
* 初始化数组的长度
*/
public StudentManager() {
this(4);
}
/**
* 由用户提供数组的长度
* @param capacity
*/
public StudentManager(int capacity) {
this.students = new Student[capacity];
}
void addStudent(Student student) {
if (index < students.length) {
students[index++] = student;
} else {
int length = students.length + (students.length >> 1);
students = Arrays.copyOf(students, length);
}
}
public static void main(String[] args) {
Student s = new Student(1,"小明");
StudentManager studentManager = new StudentManager();
for (int i = 0; i < 10; i++) {
studentManager.addStudent(s);
}
System.out.println(Arrays.toString(studentManager.students));
}
}