ZORK 学习笔记
学习笔记
1.break语句
通常用在循环bai语句和开关语句中,当break语句用于do-while、for、while循环语句中时,可使程序终止循环而执行循环后面的语句, 通常break语句总是与if语句联在一起,即满足条件时便跳出循环
2.数据结构分类
数据结构是指相互之间存在着一种或多种关系的数据元素的集合和该集合中数据元素之间的关系组成 。
常用的数据结构有:数组,栈,链表,队列,树,图,堆,散列表等
![数据结构](https://img-blog.csdnimg.cn/20210131215742376.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80OTU1NTE2Mw==,size_16,color_FFFFFF,t_70#pic_center)
3.匿名内部类写法
public static void main(String[] args) {
TreeSet<Student> students = new TreeSet<>(new Comparator<Student>() {
@Override
public int compare(Student s1, Student s2) {
int num = s1.getSum() - s2.getSum();
int num2 = num == 0 ? s1.getChinese() - s2.getChinese() : num;
int num3 = (num2 == 0) ? s1.getName().compareTo(s2.getName()) : num2;
return num3;
}
});
4.增强for写法
for (Student s : students) {
System.out.println(s.getName() + "," + s.getMath() + "," + s.getChinese() + "," + s.getSum());
}