Update doc

This commit is contained in:
icecat 2025-04-25 16:59:27 +08:00
parent 2cf455dc1f
commit 1d7f11d26d
35 changed files with 282 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

View File

@ -101,10 +101,144 @@ public static boolean equals(Object a, Object b) {
![image-20250404170313844](https://gitee.com/icecat2233/picture/raw/master/20250404170322675.png)
1. 其中binarySearch()方法,给予的数组必须是排好序的。因为使用了二分法
2. sort()方法中,对数组进行了默认升序排序,要进行其他顺序排序,需学习**红黑树**
## JDK7时间类
### Date类
<img src="https://gitee.com/icecat2233/picture/raw/master/20250410163120955.png" alt="image-20250410163119332" style="zoom:67%;" />
### SimpleDateFormat类用于日期格式化
**将Date日期转化为易懂的形式** 我个人理解为可以将这个类作为修饰Date日期对象的类。
<img src="https://gitee.com/icecat2233/picture/raw/master/20250410163252914.png" alt="image-20250410163250157" style="zoom:67%;" />
如何使用
其中在创建日期格式化对象时可以使用代参构造方法传入pattern,修改格式,代表元素如下图
```java
//创建了一个日期格式化对象,使用默认模式
SimpleDateFormat format = new SimpleDateFormat(parttern"");
//创建日期对象,封装此刻时间
Date date = new Date();
//将日期对象转换为字符串
String resul = format.format(date);
System.out.println(resul);
```
<img src="https://gitee.com/icecat2233/picture/raw/master/20250410161300015.png" alt="image-20250410161244449" style="zoom: 67%;" />
### Calendar类
表示一个时间的日历对象
#### 如何获取对象
`Calendar c = Calendar.getInstance();`
##### 常见方法
set 修改
get 获取 **注意获取月份时要进行+1操作**
**获取星期时**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250410174127785.png" alt="image-20250410174126335" style="zoom:67%;" />
add 在原有基础上添加或减少
##### 细节点:
<img src="https://gitee.com/icecat2233/picture/raw/master/20250410173853270.png" alt="image-20250410173852190" style="zoom:50%;" />
##### 案例:
```java
//键盘录入一个字符串,判断今天是今年的第几天
public class CalendarTest {
public static void main(String[] args) throws ParseException {
System.out.println("请输入你想要求的日期 格式\"xxxx年xx月xx日\"");
Scanner sc =new Scanner(System.in);
String input = sc.nextLine();
//使用SimpleDateFormat 将日期字符串转化为日期对象
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
Date riqi = format.parse(input);
//将日期对象转化为Calendar对象
Calendar c = Calendar.getInstance();
c.setTime(riqi);
//使用get方法获取第几天
int day = c.get(Calendar.DAY_OF_YEAR);
System.out.println("今天是这一年的第"+day+"天");
}
}
```
## JDK8版本后时间类常用
### 日历类 LocalDateTime
如何将字符串转化为日期对象:
**注意尽量将格式化中的MM月dd日等只写一个字符要不然容易报错**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411171745728.png" alt="image-20250411171744338" style="zoom:80%;" />
```Java
LocalDate date = LocalDate.parse(birthday, DateTimeFormatter.ofPattern("yyyy年M月d日"));
```
如何格式化日期对象
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411171614157.png" alt="image-20250411171612632" style="zoom: 80%;" />
```java
DateTimeFormatter.ofPattern("yyyy年M月d日")
```
#### 创建对象?
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411163642595.png" alt="image-20250411163640532" style="zoom:50%;" />
**LocalDate time举例 LocalTime LocalDateTime三者方法一致**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411163543670.png" alt="image-20250411163541466" style="zoom:50%;" />
#### 注意点:
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411163358361.png" alt="image-20250411163349987" style="zoom: 50%;" />
### instant时间戳类
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411165138747.png" alt="image-20250411165137534" style="zoom:50%;" />
### ZoneDateTime 带时区的时间对象
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411165733292.png" alt="image-20250411165732086" style="zoom:50%;" />
### Zoneld类(时区类)
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411165031419.png" alt="image-20250411165030046" style="zoom:50%;" />
### 时间中的工具类ChronUnit
<img src="https://gitee.com/icecat2233/picture/raw/master/20250411171007818.png" alt="image-20250411171004330" style="zoom: 67%;" />
## 基本算法:
### 1:冒泡排序

44
异常.md Normal file
View File

@ -0,0 +1,44 @@
# 异常
分为Error 和 Exception
其中Exception中 又分为两类,如图中所示
<img src="https://gitee.com/icecat2233/picture/raw/master/20250414182933522.png" alt="image-20250414182932233" style="zoom: 33%;" />
其中两种错误的表现形式有下列
![image-20250414183003770](imgh/image-20250414183003770.png)
<img src="https://gitee.com/icecat2233/picture/raw/master/20250414182755030.png" alt="image-20250414182746446" style="zoom: 67%;" />
# 异常的两种处理方式
1. **try...catch...捕获异常**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250416155305609.png" alt="image-20250416155256665" style="zoom: 50%;" />
2. **throws抛出异常**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250416155817373.png" alt="image-20250416155816351" style="zoom:50%;" />
## 两种方式怎么选择:
思路:这个问题是否需要暴漏出来?
需要暴漏用throws
不需要暴漏用try catch
## throws和throw的区别
<img src="https://gitee.com/icecat2233/picture/raw/master/20250416155752416.png" alt="image-20250416155750720" style="zoom:50%;" />
# 自定义异常
<img src="https://gitee.com/icecat2233/picture/raw/master/20250416163826822.png" alt="image-20250416163824387" style="zoom:50%;" />
# 异常中的细节
<img src="https://gitee.com/icecat2233/picture/raw/master/20250416164540545.png" alt="image-20250416164538085" style="zoom:50%;" />

View File

@ -0,0 +1,104 @@
# 集合:
**总结:**
<img src="https://gitee.com/icecat2233/picture/raw/master/20250417165937735.png" alt="image-20250417165922953" style="zoom:50%;" />
其中Collection接口中又分为**set**接口和**list**接口
## Collection:
<img src="https://gitee.com/icecat2233/picture/raw/master/20250417165721995.png" alt="image-20250417165713561" style="zoom:50%;" />
**注意事项:**
remove and contains方法依赖于底层equals方法
## 集合通用遍历方法:
### 1.迭代器 2.增强for循环 3.forEach
首先获取迭代器:
`Iterator<Student> it = c.iterator();`
其次判断循环是否还有元素
`hasNext()方法` `next()方法`
注意next()方法只调用一次,要不然会引起指针异常
### 迭代器源码解析:
![image-20250420172303418](https://gitee.com/icecat2233/picture/raw/master/20250420172317333.png)
### **三种方法演示:**
```java
public class Test2 {
public static void main(String[] args) {
Collection<Student> c = new ArrayList<>();
c.add(new Student("小鸟游六花",15));
c.add(new Student("小鸟游七花",15));
c.add(new Student("小鸟游八花",15));
//迭代器循环
Iterator<Student> it = c.iterator();
while (it.hasNext()){
Student stu = it.next();
System.out.println(stu.getName()+"---"+stu.getAge());
}
//增强for循环
for (Student stu:c){
System.out.println(stu);
}
//forEach遍历
c.forEach(student -> System.out.println(student));
}
}
```
# List集合
## list集合特点以及方法
<img src="https://gitee.com/icecat2233/picture/raw/master/20250425155619805.png" alt="image-20250425155604336" style="zoom:67%;" />
## 并发修改异常:
<img src="https://gitee.com/icecat2233/picture/raw/master/20250425154636875.png" alt="image-20250425154628294" style="zoom: 80%;" />
<img src="https://gitee.com/icecat2233/picture/raw/master/20250425155719001.png" alt="image-20250425155717100" style="zoom:80%;" />
## List集合的5种遍历方式
1. Iterator迭代器
2. 增强for循环
3. foreach
4. 普通for循环
5. ListIterator迭代器
# 数据结构:栈 队列 链表 数组
<img src="https://gitee.com/icecat2233/picture/raw/master/20250425163326284.png" alt="image-20250425163323615" style="zoom: 67%;" />
## 其中Arraylist集合扩容机制为
1. 在初始化时长度为0
2. 调用添加方法add时长度为10
3. 此后长度超过10时会将数组长度增加原来的1/2
#### **源码分析****此为长度还未超出10时的源码过程**
![image-20250425165520793](https://gitee.com/icecat2233/picture/raw/master/20250425165535349.png)
#### **此为超出10时源码过程**
![image-20250425165743512](imgh/image-20250425165743512.png)
## LinkedList特有方法
removeFirst() removeLast()